PageSourceSearch

https://noir-lang.org/docs/assets/js/74c41a71.4cdc314b.js

js noir-lang.org collected 2026-10-03 22:54:33 UTC 29,389 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[3733],{48521(e,r,s){s.r(r),s.d(r,{assets:()=>o,contentTitle:()=>a,default:()=>h,frontMatter:()=>l,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"libraries/standard_library/meta/expr","title":"Expr","description":"Introspect and transform quoted expressions at compile time\u2014inspect structure, resolve types, and modify sub-expressions.","source":"@site/processed-docs/libraries/standard_library/meta/expr.md","sourceDirName":"libraries/standard_library/meta","slug":"/libraries/standard_library/meta/expr","permalink":"/docs/dev/libraries/standard_library/meta/expr","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/docs/libraries/standard_library/meta/expr.md","tags":[],"version":"current","frontMatter":{"title":"Expr","description":"Introspect and transform quoted expressions at compile time\u2014inspect structure, resolve types, and modify sub-expressions."},"sidebar":"sidebar","previous":{"title":"CtStr
1ing","permalink":"/docs/dev/libraries/standard_library/meta/ctstring"},"next":{"title":"FunctionDefinition","permalink":"/docs/dev/libraries/standard_library/meta/function_def"}}');var i=s(74848),t=s(28453);const l={title:"Expr",description:"Introspect and transform quoted expressions at compile time\u2014inspect structure, resolve types, and modify sub-expressions."},a=void 0,o={},c=[{value:"Methods",id:"methods",level:2},{value:"as_array",id:"as_array",level:3},{value:"as_assert",id:"as_assert",level:3},{value:"as_assert_eq",id:"as_assert_eq",level:3},{value:"as_assign",id:"as_assign",level:3},{value:"as_binary_op",id:"as_binary_op",level:3},{value:"as_block",id:"as_block",level:3},{value:"as_bool",id:"as_bool",level:3},{value:"as_cast",id:"as_cast",level:3},{value:"as_comptime",id:"as_comptime",level:3},{value:"as_constructor",id:"as_constructor",level:3},{value:"as_for",id:"as_for",level:3},{value:"as_for_range",id:"as_for_range",level:3},{value:"as_function_call",id:"as_function_call",level:3},{value:"as_if",id:"as_if",level:3},{value:"as_index",id:"as_index",level:3},{value:"as_integer",id:"as_integer",level:3},{value:"as_lambda",id:"as_lambda",level:3},{value:"as_let",id:"as_let",level:3},{value:"as_member_access",id:"as_member_access",level:3},{value:"as_method_call",id:"as_method_call",level:3},{value:"as_repeated_element_array",id:"as_repeated_element_array",level:3},{value:"as_repeated_element_vector",id:"as_repeated_element_vector",level:3},{value:"as_vector",id:"as_vector",level:3},{value:"as_tuple",id:"as_tuple",level:3},{value:"as_unary_op",id:"as_unary_op",level:3},{value:"as_unsafe",id:"as_unsafe",level:3},{value:"has_semicolon",id:"has_semicolon",level:3},{value:"is_break",id:"is_break",level:3},{value:"is_continue",id:"is_continue",level:3},{value:"quoted",id:"quoted",level:3},{value:"resolve",id:"resolve",level:3}];function d(e){const r={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",sub:"sub",sup:"sup",ul:"ul",...(0,t.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.code,{children:"std::meta::expr"})," contains methods on the built-in ",(0,i.jsx)(r.code,{children:"Expr"})," type for quoted, syntactically valid expressions."]}),"\n",(0,i.jsx)(r.h2,{id:"methods",children:"Methods"}),"\n",(0,i.jsx)(r.h3,{id:"as_array",children:"as_array"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_array" showLineNumbers ',children:"pub comptime fn as_array(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L451-L453",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L451-L453"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is an array, this returns a vector of each element in the array."}),"\n",(0,i.jsx)(r.h3,{id:"as_assert",children:"as_assert"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_assert" showLineNumbers ',children:"pub comptime fn as_assert(self) -> Option<AssertExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L456-L458",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L456-L458"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is an assert, this returns its predicate and optional message."}),"\n",(0,i.jsx)(r.h3,{id:"as_assert_eq",children:"as_assert_eq"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_assert_eq" showLineNumbers ',children:"pub comptime fn as_assert_eq(self) -> Option<AssertEqExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L469-L471",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L469-L471"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is an assert_eq, this returns the left-hand-side and right-hand-side\nexpressions, together with the optional message."}),"\n",(0,i.jsx)(r.h3,{id:"as_assign",children:"as_assign"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_assign" showLineNumbers ',children:"pub comptime fn as_assign(self) -> Option<AssignExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L481-L483",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L481-L483"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is an assignment, this returns its left- and right-hand sides."}),"\n",(0,i.jsx)(r.h3,{id:"as_binary_op",children:"as_binary_op"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_binary_op" showLineNumbers ',children:"pub comptime fn as_binary_op(self) -> Option<BinaryOpExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L494-L496",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L494-L496"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a binary operator operation ",(0,i.jsx)(r.code,{children:"<lhs> <op> <rhs>"}),",\nreturn the left-hand side, operator, and the right-hand side of the operation."]}),"\n",(0,i.jsx)(r.h3,{id:"as_block",children:"as_block"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_block" showLineNumbers ',children:"pub comptime fn as_block(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L508-L510",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L508-L510"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a block ",(0,i.jsx)(r.code,{children:"{ stmt1; stmt2; ...; stmtN }"}),", return\na vector containing each statement."]}),"\n",(0,i.jsx)(r.h3,{id:"as_bool",children:"as_bool"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_bool" showLineNumbers ',children:"pub comptime fn as_bool(self) -> Option<bool> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L514-L516",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L514-L516"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is a boolean literal, return that literal."}),"\n",(0,i.jsx)(r.h3,{id:"as_cast",children:"as_cast"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_cast" showLineNumbers ',children:"pub comptime fn as_cast(self) -> Option<CastExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L520-L522",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L520-L522"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a cast expression (",(0,i.jsx)(r.code,{children:"expr as type"}),"), returns the casted\nexpression and the type to cast to."]}),"\n",(0,i.jsx)(r.h3,{id:"as_comptime",children:"as_comptime"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_comptime" showLineNumbers ',children:"pub comptime fn as_comptime(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L534-L536",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L534-L536"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a ",(0,i.jsx)(r.code,{children:"comptime { stmt1; stmt2; ...; stmtN }"})," block,\nreturn each statement in the block."]}),"\n",(0,i.jsx)(r.h3,{id:"as_constructor",children:"as_constructor"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_constructor" showLineNumbers ',children:"pub comptime fn as_constructor(self) -> Option<ConstructorExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L540-L542",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L540-L542"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a constructor ",(0,i.jsx)(r.code,{children:"Type { field1: expr1, ..., fieldN: exprN }"}),",\nreturn the type and the fields."]}),"\n",(0,i.jsx)(r.h3,{id:"as_for",children:"as_for"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_for" showLineNumbers ',children:"pub comptime fn as_for(self) -> Option<ForExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L556-L558",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L556-L558"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is a for statement over a single expression, return its identifier,\niterable, and body."}),"\n",(0,i.jsx)(r.h3,{id:"as_for_range",children:"as_for_range"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_for_range" showLineNumbers ',children:"pub comptime fn as_for_range(self) -> Option<ForRangeExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L569-L571",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L569-L571"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is a for statement over a range, return the identifier,\nthe range start, the range end, whether the range is inclusive, and the\nfor loop body."}),"\n",(0,i.jsx)(r.h3,{id:"as_function_call",children:"as_function_call"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_function_call" showLineNumbers ',children:"pub comptime fn as_function_call(self) -> Option<FunctionCallExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L588-L590",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L588-L590"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a function call ",(0,i.jsx)(r.code,{children:"foo(arg1, ..., argN)"}),", return\nthe function and a vector of each argument."]}),"\n",(0,i.jsx)(r.h3,{id:"as_if",children:"as_if"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_if" showLineNumbers ',children:"pub comptime fn as_if(self) -> Option<IfExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L602-L604",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L602-L604"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is an ",(0,i.jsx)(r.code,{children:"if condition { then_branch } else { else_branch }"}),",\nreturn the condition, then branch, and else branch. If there is no else branch,\n",(0,i.jsx)(r.code,{children:"None"})," is returned for that branch instead."]}),"\n",(0,i.jsx)(r.h3,{id:"as_index",children:"as_index"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_index" showLineNumbers ',children:"pub comptime fn as_index(self) -> Option<IndexExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L615-L617",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L615-L617"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is an index into an array ",(0,i.jsx)(r.code,{children:"array[index]"}),", return the\narray and the index."]}),"\n",(0,i.jsx)(r.h3,{id:"as_integer",children:"as_integer"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_integer" showLineNumbers ',children:"pub comptime fn as_integer(self) -> Option<IntegerLiteral> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L629-L631",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L629-L631"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is an integer literal, return its value.\nNegative integers are encoded as the equivalent negative field value."}),"\n",(0,i.jsx)(r.h3,{id:"as_lambda",children:"as_lambda"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_lambda" showLineNumbers ',children:"pub comptime fn as_lambda(self) -> Option<LambdaExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L639-L641",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L639-L641"})})})}),"\n"]}),"\n",(0,i.jsx)(r.p,{children:"If this expression is a lambda, returns the parameters, return type and body."}),"\n",(0,i.jsx)(r.h3,{id:"as_let",children:"as_let"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_let" showLineNumbers ',children:"pub comptime fn as_let(self) -> Option<LetExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L659-L661",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L659-L661"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a let statement, returns the let pattern as an ",(0,i.jsx)(r.code,{children:"Expr"}),",\nthe optional type annotation, and the assigned expression."]}),"\n",(0,i.jsx)(r.h3,{id:"as_member_access",children:"as_member_a
1ccess"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_member_access" showLineNumbers ',children:"pub comptime fn as_member_access(self) -> Option<MemberAccessExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L672-L674",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L672-L674"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a member access ",(0,i.jsx)(r.code,{children:"foo.bar"}),", return the struct/tuple\nexpression and the field. The field will be represented as a quoted value."]}),"\n",(0,i.jsx)(r.h3,{id:"as_method_call",children:"as_method_call"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_method_call" showLineNumbers ',children:"pub comptime fn as_method_call(self) -> Option<MethodCallExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L685-L687",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L685-L687"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a method call ",(0,i.jsx)(r.code,{children:"foo.bar::<generic1, ..., genericM>(arg1, ..., argN)"}),", return\nthe receiver, method name, a vector of each generic argument, and a vector of each argument."]}),"\n",(0,i.jsx)(r.h3,{id:"as_repeated_element_array",children:"as_repeated_element_array"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_repeated_element_array" showLineNumbers ',children:"pub comptime fn as_repeated_element_array(self) -> Option<RepeatedElementArrayExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L703-L705",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L703-L705"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a repeated element array ",(0,i.jsx)(r.code,{children:"[elem; length]"}),", return\nthe repeated element and the length expressions."]}),"\n",(0,i.jsx)(r.h3,{id:"as_repeated_element_vector",children:"as_repeated_element_vector"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_repeated_element_vector" showLineNumbers ',children:"pub comptime fn as_repeated_element_vector(self) -> Option<RepeatedElementVectorExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L716-L718",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L716-L718"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a repeated element vector ",(0,i.jsx)(r.code,{children:"[elem; length]"}),", return\nthe repeated element and the length expressions."]}),"\n",(0,i.jsx)(r.h3,{id:"as_vector",children:"as_vector"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_vector" showLineNumbers ',children:"pub comptime fn as_vector(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L730-L732",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L730-L732"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a vector literal ",(0,i.jsx)(r.code,{children:"@[elem1, ..., elemN]"}),",\nreturn each element of the vector."]}),"\n",(0,i.jsx)(r.h3,{id:"as_tuple",children:"as_tuple"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_tuple" showLineNumbers ',children:"pub comptime fn as_tuple(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L737-L739",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L737-L739"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a tuple ",(0,i.jsx)(r.code,{children:"(field1, ..., fieldN)"}),",\nreturn each element of the tuple."]}),"\n",(0,i.jsx)(r.h3,{id:"as_unary_op",children:"as_unary_op"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_unary_op" showLineNumbers ',children:"pub comptime fn as_unary_op(self) -> Option<UnaryOpExpression> {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L743-L745",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L743-L745"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is a unary operation ",(0,i.jsx)(r.code,{children:"<op> <rhs>"}),",\nreturn the unary operator as well as the right-hand side expression."]}),"\n",(0,i.jsx)(r.h3,{id:"as_unsafe",children:"as_unsafe"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="as_unsafe" showLineNumbers ',children:"pub comptime fn as_unsafe(self) -> Option<[Expr]> {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L757-L759",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L757-L759"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If this expression is an ",(0,i.jsx)(r.code,{children:"unsafe { stmt1; ...; stmtN }"})," block,\nreturn each statement inside in a vector."]}),"\n",(0,i.jsx)(r.h3,{id:"has_semicolon",children:"has_semicolon"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="has_semicolon" showLineNumbers ',children:"pub comptime fn has_semicolon(self) -> bool {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L778
1-L780",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L778-L780"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.code,{children:"true"})," if this expression is trailed by a semicolon. E.g."]}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{children:"comptime {\n    let expr1 = quote { 1 + 2 }.as_expr().unwrap();\n    let expr2 = quote { 1 + 2; }.as_expr().unwrap();\n\n    assert(expr1.as_binary_op().is_some());\n    assert(expr2.as_binary_op().is_some());\n\n    assert(!expr1.has_semicolon());\n    assert(expr2.has_semicolon());\n}\n"})}),"\n",(0,i.jsx)(r.h3,{id:"is_break",children:"is_break"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="is_break" showLineNumbers ',children:"pub comptime fn is_break(self) -> bool {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L784-L786",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L784-L786"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.code,{children:"true"})," if this expression is ",(0,i.jsx)(r.code,{children:"break"}),"."]}),"\n",(0,i.jsx)(r.h3,{id:"is_continue",children:"is_continue"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="is_continue" showLineNumbers ',children:"pub comptime fn is_continue(self) -> bool {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L790-L792",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L790-L792"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.code,{children:"true"})," if this expression is ",(0,i.jsx)(r.code,{children:"continue"}),"."]}),"\n",(0,i.jsx)(r.h3,{id:"quoted",children:"quoted"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="quoted" showLineNumbers ',children:"pub comptime fn quoted(self) -> Quoted {\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L795-L797",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L795-L797"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["Returns this expression as a ",(0,i.jsx)(r.code,{children:"Quoted"})," value. It's the same as ",(0,i.jsx)(r.code,{children:"quote { $self }"}),"."]}),"\n",(0,i.jsx)(r.h3,{id:"resolve",children:"resolve"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-rust",metastring:'title="resolve" showLineNumbers ',children:"pub comptime fn resolve(self, in_function: Option<FunctionDefinition>) -> TypedExpr {}\n"})}),"\n",(0,i.jsxs)(r.blockquote,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.sup,{children:(0,i.jsx)(r.sub,{children:(0,i.jsx)(r.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/expr.nr#L811-L813",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/expr.nr#L811-L813"})})})}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["Resolves and type-checks this expression and returns the result as a ",(0,i.jsx)(r.code,{children:"TypedExpr"}),"."]}),"\n",(0,i.jsxs)(r.p,{children:["The ",(0,i.jsx)(r.code,{children:"in_function"})," argument specifies where the expression is resolved:"]}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["If it's ",(0,i.jsx)(r.code,{children:"none"}
1),", the expression is resolved in the function where ",(0,i.jsx)(r.code,{children:"resolve"})," was called"]}),"\n",(0,i.jsxs)(r.li,{children:["If it's ",(0,i.jsx)(r.code,{children:"some"}),", the expression is resolved in the given function"]}),"\n"]}),"\n",(0,i.jsxs)(r.p,{children:["If any names used by this expression are not in scope or if there are any type errors,\nthis will give compiler errors as if the expression was written directly into\nthe current ",(0,i.jsx)(r.code,{children:"comptime"})," function."]})]})}function h(e={}){const{wrapper:r}={...(0,t.R)(),...e.components};return r?(0,i.jsx)(r,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},28453(e,r,s){s.d(r,{R:()=>l,x:()=>a});var n=s(96540);const i={},t=n.createContext(i);function l(e){const r=n.useContext(t);return n.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function a(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),n.createElement(t.Provider,{value:r},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.