1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[2698],{53106(e,t,r){r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"libraries/standard_library/fmtstr","title":"fmtstr","description":"Format string literals at compile time\u2014inspect raw contents or emit quoted strings for macro generation.","source":"@site/processed-docs/libraries/standard_library/fmtstr.md","sourceDirName":"libraries/standard_library","slug":"/libraries/standard_library/fmtstr","permalink":"/docs/dev/libraries/standard_library/fmtstr","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/docs/libraries/standard_library/fmtstr.md","tags":[],"version":"current","frontMatter":{"title":"fmtstr","description":"Format string literals at compile time\u2014inspect raw contents or emit quoted strings for macro generation."},"sidebar":"sidebar","previous":{"title":"Signatures","permalink":"/docs/dev/libraries/standard_library/cryptographic_primitives/signatures"},"next":{"title":"Is Unconstrained Function","permalink":"/docs/dev/libraries/standard_library/is_unconstrained"}}');var n=r(74848),i=r(28453);const o={title:"fmtstr",description:"Format string literals at compile time\u2014inspect raw contents or emit quoted strings for macro generation."},a=void 0,c={},l=[{value:"Methods",id:"methods",level:2},{value:"quoted_contents",id:"quoted_contents",level:3},{value:"as_quoted_str",id:"as_quoted_str",level:3}];function d(e){const t={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",sub:"sub",sup:"sup",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"fmtstr<N, T>"})," is the type resulting from using format string (",(0,n.jsx)(t.code,{children:'f"..."'}),")."]}),"\n",(0,n.jsx)(t.h2,{id:"methods",children:"Methods"}),"\n",(0,n.jsx)(t.h3,{id:"quoted_contents",children:"quoted_contents"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-rust",metastring:'title="quoted_contents" showLineNumbers ',children:"pub comptime fn quoted_contents(self) -> Quoted {}\n"})}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.sup,{children:(0,n.jsx)(t.sub,{children:(0,n.jsx)(t.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/format_string.nr#L6-L8",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/format_string.nr#L6-L8"})})})}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["Returns the format string contents (that is, without the leading and trailing double quotes) as a ",(0,n.jsx)(t.code,{children:"Quoted"})," value."]}),"\n",(0,n.jsx)(t.h3,{id:"as_quoted_str",children:"as_quoted_str"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-rust",metastring:'title="as_quoted_str" showLineNumbers ',children:"pub comptime fn as_quoted_str(self) -> Quoted {\n"})}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.sup,{children:(0,n.jsx)(t.sub,{children:(0,n.jsx)(t.a,{href:"https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/meta/format_string.nr#L11-L13",target:"_blank",rel:"noopener noreferrer",children:"Source code: noir_stdlib/src/meta/format_string.nr#L11-L13"})})})}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["Returns the format string contents (with the leading and trailing double quotes) as a ",(0,n.jsx)(t.code,{children:"Quoted"})," string literal (not a format string literal)."]}),"\n",(0,n.jsx)(t.p,{children:"Example:"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-rust",metastring:'title="as_quoted_str_test" showLineNumbers ',children:'comptime {\n let x = 1;\n let f: str<_> = f"x = {x}".as_quoted_str!();\n assert_eq(f, "x = 0x01");\n}\n'})}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.sup,{children:(0,n.jsx)(t.sub,{children:(0,n.jsx)(t.a,{href:"https://github.com/noir-lang/noir/blob/master/test_programs/compile_success_empty/comptime_fmt_strings/src/main.nr#L19-L25",target:"_blank",rel:"noopener noreferrer",children:"Source code: test_programs/compile_success_empty/comptime_fmt_strings/src/main.nr#L19-L25"})})})}),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},28453(e,t,r){r.d(t,{R:()=>o,x:()=>a});var s=r(96540);const n={},i=s.createContext(n);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:o(e.components),s.createElement(i.Provider,{value:t},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.