Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 703 Bytes

debug.md

File metadata and controls

35 lines (29 loc) · 703 Bytes

Debug (alias: fmt::Debug)

When deriving for enum like the following:

#[enum_derive(Debug)]
enum Enum<A, B> {
    A(A),
    B(B),
}

Code like this will be generated:

Note that it is a different implementation from #[derive(Debug)].

enum Enum<A, B> {
    A(A),
    B(B),
}

impl<A, B> ::core::fmt::Debug for Enum<A, B>
where
    A: ::core::fmt::Debug,
    B: ::core::fmt::Debug,
{
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        match self {
            Enum::A(x) => ::core::fmt::Debug::fmt(x, f),
            Enum::B(x) => ::core::fmt::Debug::fmt(x, f),
        }
    }
}