Function format_xml::fmt

source · []
pub fn fmt<F>(closure: F) -> fmt<F> where
    F: Fn(&mut Formatter<'_>) -> Result<(), Error>, 
Expand description

Returns a displayable object using the closure argument as its implementation.

let s = fmtools::fmt(|f| {
	f.write_str("display")
});
assert_eq!(s.to_string(), "display");

This is useful to insert ad-hoc formatting code:

println!("Hello {}!", fmtools::fmt(|f| {
	f.write_str("world")
}));
// Prints `Hello world!`