Skip to main content

mut_bump_format

Macro mut_bump_format 

Source
macro_rules! mut_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 mutable bump allocator, returning a MutBumpString.

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

§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 = mut_bump_format!(in &mut bump, "{greeting}, world!");
string.push_str(" How are you?");

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