macro_rules! fmt {
($arena:expr, $($arg:tt)*) => { ... };
}
Expand description
Creates a Option<Box<'_, str>>
using interpolation of run-time expressions.
The first argument fmt!
receives is an Arena
from which the string
will be allocated.
The second argument is a format string. This must be a string literal.
Additional parameters passed to fmt!
replace the {}
s contained within
the formatting string in the order given unless named or positional
parameters are used; see core::fmt
for more information.
Evaluates to None
if the arena does not have enough space remaining to
contain the formatted string.
Examples
use coca::{arena::Arena, fmt};
use core::mem::MaybeUninit;
let mut backing_region = [MaybeUninit::uninit(); 256];
let mut arena = Arena::from(&mut backing_region[..]);
let output = fmt!(arena, "test")?;
let output = fmt!(arena, "hello {}", "world!")?;