[][src]Crate fn_formats

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

BinaryFmt

Implements Binary by calling the stored closure.

ComprehensiveFmt

Implements all format traits by calling the stored closure.

ComprehensiveFmtSeparate

Implements all format traits by calling the respective stored closure.

DebugDisplayFmt

Implements Debug and Display by calling the stored closure.

DebugDisplayFmtSeparate

Implements Debug and Display by calling the respective stored closure.

DebugFmt

Implements Debug by calling the stored closure.

DisplayFmt

Implements Display by calling the stored closure.

LowerExpFmt

Implements LowerExp by calling the stored closure.

LowerHexFmt

Implements LowerHex by calling the stored closure.

OctalFmt

Implements Octal by calling the stored closure.

PointerFmt

Implements Pointer by calling the stored closure.

UpperExpFmt

Implements UpperExp by calling the stored closure.

UpperHexFmt

Implements UpperHex by calling the stored closure.