Skip to main content

format_atom

Macro format_atom 

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

Creates an Atom using interpolation of runtime expressions.

Identical to std’s format! macro, except:

  • First argument is the allocator.
  • Produces an Atom 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_atom;
let allocator = Allocator::new();

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