The enum is #[repr(Int)], #[repr(C)], or #[repr(C, Int)],
There is a variant with discriminant 0,
The variant with discriminant 0 is either fieldless, or all of its fields are Zeroable.
Also allows using the "perfect derive with additional bounds" from #196 for Zeroable on enums, where the fields for the "perfect derive" are from the variant with discriminant 0 (see the MyOption example on line 189 of derive/src/lib.rs).
Internal changes:
VariantDiscriminantIter now also gives the &'a Variant associated with the discriminant.
the comment on line 338 of derive/src/traits.rs kept getting mangled by cargo fmt, so I put it on its own line.
In derive_marker_trait_inner: let predicates = ... moved to after let fields = ..., since computing fields now requires accessing input, but predicates borrows it mutably. Does not change semantics.
generate_fields_are_trait and some other helper functions now take an Option<&Variant> to operate on if they otherwise don't support enums.
Closes #230.
Allows deriving
Zeroable
onenum
s where:#[repr(Int)]
,#[repr(C)]
, or#[repr(C, Int)]
,Zeroable
.Also allows using the "perfect derive with additional bounds" from #196 for Zeroable on enums, where the fields for the "perfect derive" are from the variant with discriminant 0 (see the
MyOption
example on line 189 of derive/src/lib.rs).Internal changes:
VariantDiscriminantIter
now also gives the&'a Variant
associated with the discriminant.cargo fmt
, so I put it on its own line.derive_marker_trait_inner
:let predicates = ...
moved to afterlet fields = ...
, since computingfields
now requires accessinginput
, butpredicates
borrows it mutably. Does not change semantics.generate_fields_are_trait
and some other helper functions now take anOption<&Variant>
to operate on if they otherwise don't support enums.cargo fmt
discriminantor
->discriminant
)