Macro fish_printf::sprintf
source · macro_rules! sprintf { ( $fmt:expr, // Format string, which should implement FormatString. $($arg:expr),* // arguments $(,)? // optional trailing comma ) => { ... }; ( => $target:expr, // target string $fmt:expr, // format string $($arg:expr),* // arguments $(,)? // optional trailing comma ) => { ... }; }
Expand description
A macro to format a string using fish_printf with C-locale formatting rules.
§Examples
use fish_printf::sprintf;
// Create a `String` from a format string.
let s = sprintf!("%0.5g", 123456.0);
assert_eq!(s, "1.2346e+05");
// Append to an existing string.
let mut s = String::new();
sprintf!(=> &mut s, "%0.5g", 123456.0);
assert_eq!(s, "1.2346e+05");