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
Binary
by 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
Debug
andDisplay
by calling the stored closure. - Debug
Display FmtSeparate - Implements
Debug
andDisplay
by calling the respective stored closure. - Debug
Fmt - Implements
Debug
by calling the stored closure. - Display
Fmt - Implements
Display
by calling the stored closure. - Lower
ExpFmt - Implements
LowerExp
by calling the stored closure. - Lower
HexFmt - Implements
LowerHex
by calling the stored closure. - Octal
Fmt - Implements
Octal
by calling the stored closure. - Pointer
Fmt - Implements
Pointer
by calling the stored closure. - Upper
ExpFmt - Implements
UpperExp
by calling the stored closure. - Upper
HexFmt - Implements
UpperHex
by calling the stored closure.