Skip to main content

format_ident

Macro format_ident 

Source
macro_rules! format_ident {
    ($alloc:expr, $($arg:tt)*) => { ... };
}
Expand description

Creates an Ident using interpolation of runtime expressions.

Identical to std’s format! macro, except:

  • First argument is the allocator.
  • Produces an Ident instead of a String.

The string is built in the arena, without allocating an intermediate String.

§Panics

Panics if a formatting trait implementation returns an error.

§Example

use oxc_allocator::Allocator;
use oxc_str::format_ident;
let allocator = Allocator::new();

let s1 = "foo";
let s2 = "bar";
let formatted = format_ident!(&allocator, "{s1}.{s2}");
assert_eq!(formatted, "foo.bar");