Macro bump_scope::bump_format

source ·
macro_rules! bump_format {
    (in $bump:expr) => { ... };
    (in $bump:expr, $($arg:tt)*) => { ... };
    (try in $bump:expr) => { ... };
    (try in $bump:expr, $($arg:tt)*) => { ... };
}
Expand description

This is like format! but allocates inside a Bump or BumpScope, returning a BumpString.

If you don’t need to push to the string after creation you can also use Bump::alloc_fmt.

§Panics

If used without try, panics on allocation failure or if a formatting trait implementation returns an error.

§Errors

If used with try, errors on allocation failure or if a formatting trait implementation returns an error.

§Examples

let greeting = "Hello";
let mut string = bump_format!(in bump, "{greeting} world!");
string.push_str(" How are you?");

assert_eq!(string, "Hello world! How are you?");