mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 22:32:23 +00:00
Add more Zeroable
and ZeroableInOption
impls (#158)
This commit is contained in:
parent
f276289a9a
commit
2548e460cb
@ -53,8 +53,17 @@ unsafe impl Zeroable for f64 {}
|
||||
unsafe impl<T: Zeroable> Zeroable for Wrapping<T> {}
|
||||
unsafe impl<T: Zeroable> Zeroable for core::cmp::Reverse<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`.
|
||||
unsafe impl<T> Zeroable for *mut T {}
|
||||
unsafe impl<T> Zeroable for *const T {}
|
||||
unsafe impl<T> Zeroable for *mut [T] {}
|
||||
unsafe impl<T> Zeroable for *const [T] {}
|
||||
unsafe impl Zeroable for *mut str {}
|
||||
unsafe impl Zeroable for *const str {}
|
||||
|
||||
unsafe impl<T: Zeroable> Zeroable for PhantomData<T> {}
|
||||
unsafe impl Zeroable for PhantomPinned {}
|
||||
unsafe impl<T: Zeroable> Zeroable for ManuallyDrop<T> {}
|
||||
|
@ -25,4 +25,10 @@ unsafe impl ZeroableInOption for NonZeroU64 {}
|
||||
unsafe impl ZeroableInOption for NonZeroU128 {}
|
||||
unsafe impl ZeroableInOption for NonZeroUsize {}
|
||||
|
||||
unsafe impl<T> ZeroableInOption for NonNull<T> {}
|
||||
// Note: this does not create NULL vtable because we get `None` anyway.
|
||||
unsafe impl<T: ?Sized> ZeroableInOption for NonNull<T> {}
|
||||
unsafe impl<T: ?Sized> ZeroableInOption for &'_ T {}
|
||||
unsafe impl<T: ?Sized> ZeroableInOption for &'_ mut T {}
|
||||
|
||||
#[cfg(feature = "extern_crate_alloc")]
|
||||
unsafe impl<T: ?Sized> ZeroableInOption for alloc::boxed::Box<T> {}
|
||||
|
Loading…
Reference in New Issue
Block a user