Macro strfmt::strfmt

source ·
macro_rules! strfmt {
    ($inst:expr, $($key:ident => $value:tt),*,) => { ... };
    ($inst:expr, $($values:tt),*,) => { ... };
    ($inst:expr,$($values:tt)*) => { ... };
}
Expand description

Format a given string with the passed variables. This macro is creating an single used Hashmap, for performance optimizations it might be more efficient to reuse an existing one.

Arguments

  • inst - A string with an Rust-style format instructions
  • values - A list of values to use for formatting

Errors

see strfmt

Example

use strfmt::FmtError;
use strfmt::{strfmt,strfmt_builder};

let fmt = "{first}{second:7.2}";
// ... do stuff and adjust fmt as you need
let first = "test";
//test  77.65
println!("{}",strfmt!(fmt, first,second => 77.6543210).unwrap());