The code around the Zeroable and ZeroableOption traits in src/lib.rs has evolved and can benefit from some cleanup for clarity and maintainability.
-
Reorder definitions and implementations
- Ensure consistency in placement: put the
Zeroable trait and its implementations (including macro invocations) first in the relevant section of src/lib.rs, followed by the ZeroableOption trait and its implementations.
- This includes all macro definitions & uses related to these traits.
-
Rename macro for clarity
- One of the macros is currently named
impl_non_zero_int_zeroable_option; it should be renamed to impl_zeroable_option for consistency.
-
Macro usage for generic impls
- Use the
impl_zeroable_option macro to handle generic impls for types like &T, &mut T, NonNull<T>, and others (for which Option<T> is guaranteed to be zeroable).
- This requires modifying the macro to support generics like
impl_zeroable.
Please make sure your changes abide by the Linux kernel's contribution rules. Before submitting a PR, read and follow the guidelines in CONTRIBUTING.md.
The code around the
ZeroableandZeroableOptiontraits insrc/lib.rshas evolved and can benefit from some cleanup for clarity and maintainability.Reorder definitions and implementations
Zeroabletrait and its implementations (including macro invocations) first in the relevant section ofsrc/lib.rs, followed by theZeroableOptiontrait and its implementations.Rename macro for clarity
impl_non_zero_int_zeroable_option; it should be renamed toimpl_zeroable_optionfor consistency.Macro usage for generic impls
impl_zeroable_optionmacro to handle generic impls for types like&T,&mut T,NonNull<T>, and others (for whichOption<T>is guaranteed to be zeroable).impl_zeroable.Please make sure your changes abide by the Linux kernel's contribution rules. Before submitting a PR, read and follow the guidelines in CONTRIBUTING.md.