Skip to main content

bump_format

Macro 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 allocator, 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?");