1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 /// Encapsulates the requirement that 4 /// `MaybeUninit::<Self>::zeroed().assume_init()` does not cause 5 /// undefined behavior. 6 /// 7 /// # Safety 8 /// 9 /// Do not add this trait to a type unless all-zeroes is 10 /// a valid value for the type. In particular, remember that raw 11 /// pointers can be zero, but references and `NonNull<T>` cannot 12 /// unless wrapped with `Option<>`. 13 pub unsafe trait Zeroable: Default { 14 /// SAFETY: If the trait was added to a type, then by definition 15 /// this is safe. 16 const ZERO: Self = unsafe { ::core::mem::MaybeUninit::<Self>::zeroed().assume_init() }; 17 } 18 19 unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 {} 20 unsafe impl Zeroable for crate::bindings::Property {} 21 unsafe impl Zeroable for crate::bindings::VMStateDescription {} 22 unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 {} 23 unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 {} 24