Skip to main content

formatx

Macro formatx 

Source
macro_rules! formatx {
    ($template:expr $(,)?) => { ... };
    ($template:expr, $($args:tt)*) => { ... };
}
Expand description

Format a runtime string in strict mode.

Returns Result<String, Error>. Produces Error::MissingArgument if any placeholder references an argument that was not provided.

ยงExamples

use formatx::formatx;

let template = "{name} has {count} items";
let result = formatx!(template, name = "Alice", count = 42).unwrap();
assert_eq!(result, "Alice has 42 items");

// Positional arguments:
let result = formatx!("{} + {} = {}", 1, 2, 3).unwrap();
assert_eq!(result, "1 + 2 = 3");