deser-debug
Formats any value that implements deser's Serialize like
#[derive(Debug)] would. This is useful when a type is serializable but
does not implement Debug (for instance because you want to keep the
compile time and binary size of a second derive off your types), when you
are generic over Serialize and want to log values, or when you want to
implement Debug in terms of Serialize.
The Rust shape of values (struct and variant names, Option, tuples, ...)
is taken from their description (see deser::ser::Describe), so for
derived types the output matches what #[derive(Debug)] produces,
including pretty printing with {:#?}:
use Serialize;
use ToDebug;
let shape = Circle ;
assert_eq!;
Note that the output shows the Rust value, not the serialized form: the
internally tagged enum above is still shown as a Circle variant rather
than a map with a type key.
Names are the ones used when serializing: renamed types, variants and
fields (for instance with rename_all = "camelCase") are shown with their
new names, variants named by integers are shown as numbers and the fields
of flattened structs are shown in the struct they are flattened into. Only
the shape is taken from the description, which keeps it cheap: types do
not carry any extra information for formatting.