Macro format_in

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

Creates a new String with the specified allocator and formats the arguments into it.

This macro is similar to the standard library’s format! macro but returns our allocator-aware String.

§Examples

#![feature(allocator_api)]
use string_alloc::{String, format_in};
use std::alloc::Global;

let name = "World";
let s = format_in!(Global, "Hello, {}!", name);
assert_eq!(&*s, "Hello, World!");