Derive Macro MaybeZeroable

Source
#[derive(MaybeZeroable)]
Expand description

Derives the Zeroable trait for the given struct or union if all fields implement Zeroable.

Contrary to the derive macro named Zeroable, this one silently fails when a field doesn’t implement Zeroable.

§Examples

use pin_init::MaybeZeroable;

// implmements `Zeroable`
#[derive(MaybeZeroable)]
pub struct DriverData {
    pub(crate) id: i64,
    buf_ptr: *mut u8,
    len: usize,
}

// does not implmement `Zeroable`
#[derive(MaybeZeroable)]
pub struct DriverData2 {
    pub(crate) id: i64,
    buf_ptr: *mut u8,
    len: usize,
    // this field doesn't implement `Zeroable`
    other_data: &'static i32,
}