#[repr(C)]pub struct PodBool(/* private fields */);
Expand description
A version of bool
that has the same layout as bool
but is bytemuck::Pod
.
In Rust, bool
has a defined representation of being one byte with false being 0 and true being 1.
However, it is not Pod
because it is invalid to interpret a byte that contains any value other
than 0 or 1 as a bool
– doing so is undefined behavior.
Use this type to get around that limitation, as PodBool
is valid for any value of u8
, and its value is
checked to be valid as a bool
upon calling as_bool
Implementations§
Trait Implementations§
impl Copy for PodBool
impl Eq for PodBool
impl Pod for PodBool
impl StructuralPartialEq for PodBool
Auto Trait Implementations§
impl Freeze for PodBool
impl RefUnwindSafe for PodBool
impl Send for PodBool
impl Sync for PodBool
impl Unpin for PodBool
impl UnwindSafe for PodBool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.