zerofrom

Derive Macro ZeroFrom

source
#[derive(ZeroFrom)]
{
    // Attributes available to this derive:
    #[zerofrom]
}
Expand description

Custom derive for zerofrom::ZeroFrom,

This implements ZeroFrom<Ty> for Ty for types without a lifetime parameter, and ZeroFrom<Ty<'data>> for Ty<'static> for types with a lifetime parameter.

Apply the #[zerofrom(clone)] attribute to a field if it doesn’t implement Copy or ZeroFrom; this data will be cloned when the struct is zero_from’ed.

Apply the #[zerofrom(maybe_borrow(T, U, V))] attribute to the struct to indicate that certain type parameters may themselves contain borrows (by default the derives assume that type parameters perform no borrows and can be copied or cloned).

In rust versions where this issue is fixed, #[zerofrom(may_borrow)] can be applied directly to type parameters.