rune::alloc::fmt

Function try_format

Source
pub fn try_format(args: Arguments<'_>) -> Result<String, Error>
Expand description

The format function takes an Arguments struct and returns the resulting formatted string.

The Arguments instance can be created with the format_args! macro.

ยงExamples

Basic usage:

use rune::alloc::fmt;

let s = fmt::try_format(format_args!("Hello, {}!", "world"))?;
assert_eq!(s, "Hello, world!");

Please note that using try_format! might be preferable. Example:

use rune::alloc::try_format;

let s = try_format!("Hello, {}!", "world");
assert_eq!(s, "Hello, world!");