pub unsafe trait Zeroable {
// Provided methods
fn init_zeroed() -> impl Init<Self>
where Self: Sized { ... }
fn zeroed() -> Self
where Self: Sized { ... }
}Expand description
Provided Methods§
Sourcefn init_zeroed() -> impl Init<Self>where
Self: Sized,
fn init_zeroed() -> impl Init<Self>where
Self: Sized,
Create a new zeroed Self.
The returned initializer will write 0x00 to every byte of the given slot.
Sourcefn zeroed() -> Selfwhere
Self: Sized,
fn zeroed() -> Selfwhere
Self: Sized,
Create a Self consisting of all zeroes.
Whenever a type implements Zeroable, this function should be preferred over
core::mem::zeroed() or using MaybeUninit<T>::zeroed().assume_init().
§Examples
use pin_init::{Zeroable, zeroed};
#[derive(Zeroable)]
struct Point {
x: u32,
y: u32,
}
let point: Point = zeroed();
assert_eq!(point.x, 0);
assert_eq!(point.y, 0);Implementations on Foreign Types§
impl Zeroable for bool
impl Zeroable for char
impl Zeroable for f32
impl Zeroable for f64
impl Zeroable for i8
impl Zeroable for i16
impl Zeroable for i32
impl Zeroable for i64
impl Zeroable for i128
impl Zeroable for isize
impl Zeroable for *const str
impl Zeroable for *mut str
impl Zeroable for u8
impl Zeroable for u16
impl Zeroable for u32
impl Zeroable for u64
impl Zeroable for u128
impl Zeroable for ()
impl Zeroable for usize
impl Zeroable for PhantomPinned
impl<J: Zeroable> Zeroable for (J₁, J₂, …, Jₙ)
Implemented for tuples up to 10 items long.