/// Trait for types that can be safely created with /// [`zeroed`](core::mem::zeroed). /// /// An all-zeroes value may or may not be the same value as the /// [Default](core::default::Default) value of the type. /// /// ## Safety /// /// * Your type must be inhabited (eg: no /// [Infallible](core::convert::Infallible)). /// * Your type must be allowed to be an "all zeroes" bit pattern (eg: no /// [`NonNull<T>`](core::ptr::NonNull)). /// /// ## Features /// /// Some `impl`s are feature gated due to the MSRV policy: /// /// * `MaybeUninit<T>` was not available in 1.34.0, but is available under the /// `zeroable_maybe_uninit` feature flag. /// * `Atomic*` types require Rust 1.60.0 or later to work on certain platforms, /// but is available under the `zeroable_atomics` feature flag. /// * `[T; N]` for arbitrary `N` requires the `min_const_generics` feature flag. pubunsafetrait Zeroable: Sized { /// Calls [`zeroed`](core::mem::zeroed). /// /// This is a trait method so that you can write `MyType::zeroed()` in your /// code. It is a contract of this trait that if you implement it on your type /// you **must not** override this method. #[inline] fn zeroed() -> Self { unsafe { core::mem::zeroed() }
}
} unsafeimpl Zeroable for () {} unsafeimpl Zeroable for bool {} unsafeimpl Zeroable for char {} unsafeimpl Zeroable for u8 {} unsafeimpl Zeroable for i8 {} unsafeimpl Zeroable for u16 {} unsafeimpl Zeroable for i16 {} unsafeimpl Zeroable for u32 {} unsafeimpl Zeroable for i32 {} unsafeimpl Zeroable for u64 {} unsafeimpl Zeroable for i64 {} unsafeimpl Zeroable for usize {} unsafeimpl Zeroable for isize {} unsafeimpl Zeroable for u128 {} unsafeimpl Zeroable for i128 {} #[cfg(feature = "nightly_float")] unsafeimpl Zeroable for f16 {} unsafeimpl Zeroable for f32 {} unsafeimpl Zeroable for f64 {} #[cfg(feature = "nightly_float")] unsafeimpl Zeroable for f128 {} unsafeimpl<T: Zeroable> Zeroable for Wrapping<T> {} unsafeimpl<T: Zeroable> Zeroable for core::cmp::Reverse<T> {} #[cfg(feature = "pod_saturating")] unsafeimpl<T: Zeroable> Zeroable for core::num::Saturating<T> {}
// Note: we can't implement this for all `T: ?Sized` types because it would // create NULL pointers for vtables. // Maybe one day this could be changed to be implemented for // `T: ?Sized where <T as core::ptr::Pointee>::Metadata: Zeroable`. unsafeimpl<T> Zeroable for *mut T {} unsafeimpl<T> Zeroable for *const T {} unsafeimpl<T> Zeroable for *mut [T] {} unsafeimpl<T> Zeroable for *const [T] {} unsafeimpl Zeroable for *mut str {} unsafeimpl Zeroable for *const str {}
unsafeimpl<T: ?Sized> Zeroable for PhantomData<T> {} unsafeimpl Zeroable for PhantomPinned {} unsafeimpl<T: Zeroable> Zeroable for core::mem::ManuallyDrop<T> {} unsafeimpl<T: Zeroable> Zeroable for core::cell::UnsafeCell<T> {} unsafeimpl<T: Zeroable> Zeroable for core::cell::Cell<T> {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.