Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/docs/noir/standard_library/fmtstr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ title: fmtstr

#include_code quoted_contents noir_stdlib/src/meta/format_string.nr rust

Returns the format string contents (that is, without the leading and trailing double quotes) as a `Quoted` value.
Returns the format string contents (that is, without the leading and trailing double quotes) as a `Quoted` value.

### as_quoted_str

#include_code as_quoted_str noir_stdlib/src/meta/format_string.nr rust

Returns the format string contents (with the leading and trailing double quotes) as a `Quoted` string literal (not a format string literal).

Example:

#include_code as_quoted_str_test test_programs/compile_success_empty/comptime_fmt_strings/src/main.nr rust
10 changes: 10 additions & 0 deletions noir_stdlib/src/meta/format_string.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
use super::ctstring::AsCtString;

impl<let N: u32, T> fmtstr<N, T> {
/// Returns the format string contents (that is, without the leading and trailing double quotes) as a `Quoted` value.
#[builtin(fmtstr_quoted_contents)]
// docs:start:quoted_contents
pub comptime fn quoted_contents(self) -> Quoted {}
// docs:end:quoted_contents

/// Returns the format string contents (with the leading and trailing double quotes) as a `Quoted` string literal (not a format string literal).
// docs:start:as_quoted_str
pub comptime fn as_quoted_str(self) -> Quoted {
// docs:end:as_quoted_str
self.as_ctstring().as_quoted_str()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ fn main() {

// Mainly test fmtstr::quoted_contents
call!(glue(quote { hello }, quote { world }));

// docs:start:as_quoted_str_test
comptime {
let x = 1;
let f: str<_> = f"x = {x}".as_quoted_str!();
assert_eq(f, "x = 0x01");
}
// docs:end:as_quoted_str_test
}

comptime fn glue(x: Quoted, y: Quoted) -> Quoted {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading