Function sprintf::vsprintf

source ·
pub fn vsprintf(format: &str, args: &[&dyn Printf]) -> Result<String>
Expand description

Format a string. (Roughly equivalent to vsnprintf or vasprintf in C)

Takes a printf-style format string format and a slice of dynamically typed arguments, args.

use sprintf::{vsprintf, Printf};
let n = 16;
let args: Vec<&dyn Printf> = vec![&n];
let s = vsprintf("%#06x", &args).unwrap();
assert_eq!(s, "0x0010");

See also: sprintf