#[repr(transparent)]
pub struct Bits<T>(pub T);
Expand description
Wrapper to provide access to bit fields
use lazy_bytes_cast::Bits;
let mut bits = Bits(u32::max_value());
assert!(!bits.empty());
assert!(bits.get(1));
bits = bits.set(1);
assert!(bits.get(1));
bits = bits.toggle(1);
assert!(!bits.get(1));
bits = bits.unset(1);
assert!(!bits.get(1));
bits = bits.toggle(1);
assert!(bits.get(1));
bits = bits.reset();
assert_eq!(bits, 0);
assert!(bits.empty());
assert!(!bits.get(1));
assert_eq!(bits.len(), core::mem::size_of_val(&bits) * 8);
bits = Bits(u32::min_value());
assert!(bits.empty());
assert!(!bits.get(1));
bits = bits.set(1);
assert!(bits.get(1));
bits = bits.unset(1);
assert!(!bits.get(1));
bits = bits.set(26);
assert!(bits.get(26));
assert!(bits.get(90)); bits = bits.set(91);
assert!(bits.get(26));
bits = bits.flip();
assert!(!bits.get(26));
assert!(bits.get(5));
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Set bit by index and return updated value.
Unset bit by index and return updated value.
Unset bit by index and return updated value.
Returns whether all bits are unset
Unset all bits and returns updated value
Flip all bits and returns updated value
Returns number of bits inside.
Returns number of bits inside.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Formats the value using the given formatter.
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Returns the “default value” for a type.
Read more
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Mutably dereferences the value.
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Formats the value using the given formatter.
Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.