Lines Matching defs:Zeroable

398 /// Derives the [`Zeroable`] trait for the given `struct` or `union`.
400 /// This can only be used for `struct`s/`union`s where every field implements the [`Zeroable`]
406 /// use pin_init::Zeroable;
408 /// #[derive(Zeroable)]
417 /// use pin_init::Zeroable;
419 /// #[derive(Zeroable)]
425 pub use ::pin_init_internal::Zeroable;
427 /// Derives the [`Zeroable`] trait for the given `struct` or `union` if all fields implement
428 /// [`Zeroable`].
430 /// Contrary to the derive macro named [`macro@Zeroable`], this one silently fails when a field
431 /// doesn't implement [`Zeroable`].
438 /// // implmements `Zeroable`
446 /// // does not implmement `Zeroable`
452 /// // this field doesn't implement `Zeroable`
747 /// - Using struct update syntax one can place `..Zeroable::init_zeroed()` at the very end of the
749 /// body. This can only be done if [`Zeroable`] is implemented for the struct.
757 /// #[derive(Zeroable)]
774 /// ..Zeroable::init_zeroed()
1500 pub unsafe trait Zeroable {
1514 /// Whenever a type implements [`Zeroable`], this function should be preferred over
1520 /// use pin_init::{Zeroable, zeroed};
1522 /// #[derive(Zeroable)]
1545 /// The implementer needs to ensure that `unsafe impl Zeroable for Option<Self> {}` is sound.
1549 unsafe impl<T: ZeroableOption> Zeroable for Option<T> {}
1565 pub fn init_zeroed<T: Zeroable>() -> impl Init<T> {
1566 // SAFETY: Because `T: Zeroable`, all bytes zero is a valid bit pattern for `T`
1578 /// Whenever a type implements [`Zeroable`], this function should be preferred over
1584 /// use pin_init::{Zeroable, zeroed};
1586 /// #[derive(Zeroable)]
1596 pub const fn zeroed<T: Zeroable>() -> T {
1597 // SAFETY:By the type invariants of `Zeroable`, all zeroes is a valid bit pattern for `T`.
1604 $(unsafe impl$($($generics)*)? Zeroable for $t {})*
1629 // SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`.
1630 {<T: ?Sized + Zeroable>} UnsafeCell<T>,
1645 // `T: ?Sized where <T as Pointee>::Metadata: Zeroable`
1652 // SAFETY: `T` is `Zeroable`.
1653 {<const N: usize, T: Zeroable>} [T; N], {<T: Zeroable>} Wrapping<T>,
1660 unsafe impl<$first: Zeroable, $($t: Zeroable),*> Zeroable for ($first, $($t),*) {}