Expand description
This is a small shim library for passing closures where you need a format trait.
§Example
use fn_formats::DebugFmt;
let formattable = DebugFmt(|f| {
f.debug_struct("StructName")
.field("list", &DebugFmt(|f| f.debug_list().entries(&[1, 2, 3]).finish()))
.field("set", &DebugFmt(|f| f.debug_set().entries(&[4, 5, 6]).finish()))
.finish()
});
assert_eq!(format!("{:?}", formattable), "StructName { list: [1, 2, 3], set: {4, 5, 6} }");There are also From implementations where applicable:
use fn_formats::ComprehensiveFmt;
let _: ComprehensiveFmt<_> = (|f: &mut core::fmt::Formatter| Ok(())).into();Structs§
- Binary
Fmt - Implements
Binaryby calling the stored closure. - Comprehensive
Fmt - Implements all format traits by calling the stored closure.
- Comprehensive
FmtSeparate - Implements all format traits by calling the respective stored closure.
- Debug
Display Fmt - Implements
DebugandDisplayby calling the stored closure. - Debug
Display FmtSeparate - Implements
DebugandDisplayby calling the respective stored closure. - Debug
Fmt - Implements
Debugby calling the stored closure. - Display
Fmt - Implements
Displayby calling the stored closure. - Lower
ExpFmt - Implements
LowerExpby calling the stored closure. - Lower
HexFmt - Implements
LowerHexby calling the stored closure. - Octal
Fmt - Implements
Octalby calling the stored closure. - Pointer
Fmt - Implements
Pointerby calling the stored closure. - Upper
ExpFmt - Implements
UpperExpby calling the stored closure. - Upper
HexFmt - Implements
UpperHexby calling the stored closure.