fmt_fn

Function fmt_fn 

Source
pub const fn fmt_fn<F>(f: F) -> FmtFn<F>
where F: Fn(&mut Formatter<'_>) -> Result,
Expand description

Creates an object that implements Debug and Display based on the provided function object.

Example:

let fmt = fmt_tools::fmt_fn(|f| f.write_str("foo"));

assert_eq!(format!("{fmt:?}"), "foo");
assert_eq!(format!("{fmt}"), "foo");