Skip to main content

union_with_debug

Macro union_with_debug 

Source
macro_rules! union_with_debug {
    (
        $(#$attr:tt)*
        $vis:vis union $name:ident { $($body:tt)* }
    ) => { ... };
    (
        @split_attrs,
        cfg_attrs: { $($cfg_attrs:tt)* },
        other_attrs: { $($other_attrs:tt)* },
        remaining_attrs: {
            #[cfg($($cfg:tt)*)]
            $($tail:tt)*
        },
        found_default_via_unsafe_zeroed: $found_default:tt,
        vis: $vis:vis,
        name: $name:ident,
        body: { $($body:tt)* },
    ) => { ... };
    (
        @split_attrs,
        cfg_attrs: { $($cfg_attrs:tt)* },
        other_attrs: { $($other_attrs:tt)* },
        remaining_attrs: {
            #[unsafe(union_default_via_zeroed)]
            $($tail:tt)*
        },
        found_default_via_unsafe_zeroed: $found_default:tt,
        vis: $vis:vis,
        name: $name:ident,
        body: { $($body:tt)* },
    ) => { ... };
    (
        @split_attrs,
        cfg_attrs: { $($cfg_attrs:tt)* },
        other_attrs: { $($other_attrs:tt)* },
        remaining_attrs: {
            #$other:tt
            $($tail:tt)*
        },
        found_default_via_unsafe_zeroed: $found_default:tt,
        vis: $vis:vis,
        name: $name:ident,
        body: { $($body:tt)* },
    ) => { ... };
    (
        @split_attrs,
        cfg_attrs: { $($cfg_attrs:tt)* },
        other_attrs: { $($other_attrs:tt)* },
        remaining_attrs: { },
        found_default_via_unsafe_zeroed: $found_default:tt,
        vis: $vis:vis,
        name: $name:ident,
        body: { $($body:tt)* },
    ) => { ... };
}
Expand description

Emit a union plus its Debug impl.

Unions can’t derive Debug, so it is written out here. Attributes are split like [custom_struct] does. Everything goes on the union, but only the cfgs are repeated on the impl, otherwise a union that is configured out leaves an impl behind.