Skip to main content

Bitset8

Struct Bitset8 

Source
pub struct Bitset8(/* private fields */);
Expand description

Bitset of bit size 8.

Implementations§

Source§

impl Bitset8

Source

pub const fn new(inner: u8) -> Self

Constructs a new value of Bitset8.

§Examples
use bitworks::prelude::{Bitset, Bitset8};

let bitset = Bitset8::new(19);

assert_eq!(bitset, Bitset8::from_repr(19));
Source

pub const fn into_inner(&self) -> u8

Returns the inner u8 representation of Bitset8.

§Examples
use bitworks::prelude::Bitset8;

let bitset = Bitset8::new(19);
let inner: u8 = bitset.into_inner();

assert_eq!(inner, 19);

Trait Implementations§

Source§

impl Binary for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl BitAnd for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAnd<Index<Bitset8>> for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Index<Bitset8>) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for Bitset8

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitAndAssign<Index<Bitset8>> for Bitset8

Source§

fn bitand_assign(&mut self, rhs: Index<Bitset8>)

Performs the &= operation. Read more
Source§

impl BitOr for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr<Index<Bitset8>> for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Index<Bitset8>) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for Bitset8

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitOrAssign<Index<Bitset8>> for Bitset8

Source§

fn bitor_assign(&mut self, rhs: Index<Bitset8>)

Performs the |= operation. Read more
Source§

impl BitXor for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<Index<Bitset8>> for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Index<Bitset8>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Bitset8

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl BitXorAssign<Index<Bitset8>> for Bitset8

Source§

fn bitxor_assign(&mut self, rhs: Index<Bitset8>)

Performs the ^= operation. Read more
Source§

impl Clone for Bitset8

Source§

fn clone(&self) -> Bitset8

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Bitset8

Source§

impl Debug for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Bitset8

Source§

fn default() -> Bitset8

Returns the “default value” for a type. Read more
Source§

impl Display for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Bitset8

Source§

impl From<Bitset8> for Bitset128

Source§

fn from(value: Bitset8) -> Self

Converts to this type from the input type.
Source§

impl From<Bitset8> for Bitset16

Source§

fn from(value: Bitset8) -> Self

Converts to this type from the input type.
Source§

impl From<Bitset8> for Bitset32

Source§

fn from(value: Bitset8) -> Self

Converts to this type from the input type.
Source§

impl From<Bitset8> for Bitset64

Source§

fn from(value: Bitset8) -> Self

Converts to this type from the input type.
Source§

impl From<Bitset8> for u8

Source§

fn from(value: Bitset8) -> Self

Converts to this type from the input type.
Source§

impl From<Byteset<1>> for Bitset8

Source§

fn from(value: Byteset<1>) -> Self

Converts to this type from the input type.
Source§

impl From<Index<Bitset8>> for Bitset8

Source§

fn from(value: Index<Bitset8>) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Bitset8

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Bit> for Bitset8

Source§

fn from_iter<T: IntoIterator<Item = Bit>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Bitset8

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LeftAligned for Bitset8

Source§

fn shift_left(self, amount: Index<Self>) -> Self

Shifts bit representation of the Bitset left by amount. Has signature and use identical to core::ops::Shl<Index<Self>>.
Source§

fn shift_right(self, amount: Index<Self>) -> Self

Shifts bit representation of the Bitset right by amount. Has signature and use identical to core::ops::Shr<Index<Self>>.
Source§

impl LowerHex for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Not for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Octal for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Ord for Bitset8

Source§

fn cmp(&self, other: &Bitset8) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Bitset8

Source§

fn eq(&self, other: &Bitset8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Bitset8

Source§

fn partial_cmp(&self, other: &Bitset8) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Shl<Index<Bitset8>> for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: Index<Bitset8>) -> Self::Output

Performs the << operation. Read more
Source§

impl ShlAssign<Index<Bitset8>> for Bitset8

Source§

fn shl_assign(&mut self, rhs: Index<Bitset8>)

Performs the <<= operation. Read more
Source§

impl Shr<Index<Bitset8>> for Bitset8

Source§

type Output = Bitset8

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: Index<Bitset8>) -> Self::Output

Performs the >> operation. Read more
Source§

impl ShrAssign<Index<Bitset8>> for Bitset8

Source§

fn shr_assign(&mut self, rhs: Index<Bitset8>)

Performs the >>= operation. Read more
Source§

impl StructuralPartialEq for Bitset8

Source§

impl TryFrom<Bitset16> for Bitset8

Source§

type Error = ConvError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bitset16) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bitset32> for Bitset8

Source§

type Error = ConvError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bitset32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bitset64> for Bitset8

Source§

type Error = ConvError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bitset64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bitset128> for Bitset8

Source§

type Error = ConvError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bitset128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpperHex for Bitset8

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Bitset for T
where T: LeftAligned + Clone + PartialEq + Eq,

Source§

const BYTE_SIZE: usize = const BYTE_SIZE: usize = Self::_BYTE_SIZE;

Number of bytes (size in bytes) of the bitset part. Read more
Source§

const NONE: T = const NONE: Self = Self::_NONE;

Value of the Bitset with every bit not set. Read more
Source§

const ALL: T = const ALL: Self = Self::_ALL;

Value of the Bitset with every bit set. Read more
Source§

type Repr = <T as LeftAligned>::_Repr

Type, that is the underlying representation of the Bitset.
Usually one of the Rust built-in types, but can be another Bitset or even Self.
Source§

type Size = <T as LeftAligned>::_Size

Marker type representing size ordering. Used for compile time checks on some methods.
Source§

fn from_repr(value: <T as Bitset>::Repr) -> T

Constructs a new value of the Bitset from Bitset::Repr. Read more
Source§

fn from_index(index: &Index<T>) -> T

Constructs Bitset from Index. The resulting value always has only bit at index set. Read more
Source§

fn count_ones(&self) -> usize

Returns the count of all set bits. Read more
Source§

fn count_zeros(&self) -> usize

Returns the number of all unset bits. Read more
Source§

fn set(&mut self, index: Index<T>) -> &mut T

Sets bit at index. Returns a mutable reference to self. Read more
Source§

fn unset(&mut self, index: Index<T>) -> &mut T

Unsets bit at index. Returns a mutable reference to self. Read more
Source§

fn flip(&mut self, index: Index<T>) -> &mut T

Flips bit at index. Returns a mutable reference to self. Read more
Source§

fn include(&mut self, other: T) -> &mut T

Includes all set bits of other in self. Returns a mutable reference to self. Read more
Source§

fn exclude(&mut self, other: T) -> &mut T

Excludes all set bits of other from self. Returns a mutable reference to self. Read more
Source§

fn bit(&self, index: Index<T>) -> Bit

Returns a copy of the Bit at index. Read more
Source§

fn bit_ref(&self, index: Index<T>) -> BitRef<'_, T>

Returns a BitRef holding an immutable reference to the bit at index. Read more
Source§

fn bit_mut(&mut self, index: Index<T>) -> BitMut<'_, T>

Returns a BitMut holding a mutable reference to the bit at index. Read more
Source§

fn complement(self) -> T

Returns Set complement (self′) of Bitset.
Alias for ! operator. Read more
Source§

fn union(self, other: T) -> T

Returns Set union (self ∪ other) of two Bitsets.
Alias for | operator. Read more
Source§

fn intersection(self, other: T) -> T

Returns Set intersection (self ∩ other) of two Bitsets.
Alias for & operator. Read more
Source§

fn difference(self, other: T) -> T

Returns Set difference (self \ other) of two Bitsets. Read more
Source§

fn sym_difference(self, other: T) -> T

Returns Set symmetric difference (self Δ other) of two Bitsets.
Alias for ^ operator. Read more
Source§

fn includes(&self, other: &T) -> bool

Returns true, if self contains all of the set bits from other and false otherwise. Read more
Source§

fn intersects(&self, other: &T) -> bool

Returns true, if self shares any set bits with other and false otherwise. Read more
Source§

fn build(&mut self) -> Self

Build Bitset from a mutable reference. Read more
Source§

fn expand<Res>(self) -> Res
where Res: Bitset, Self::Size: Smaller<Res::Size>,

Expands Bitset to a bigger one.
If available, you should prefer using Bitset::expand_optimized. Read more
Source§

fn expand_optimized<Res>(self) -> Res
where Self: LeftAligned, Res: Bitset + LeftAligned, Self::Size: Smaller<Res::Size>,

Expands Bitset to a bigger one. Uses unsafe optimizations. Read more
Source§

fn from_iterable<'a, I>(iterable: I) -> Self
where Self: 'a, I: IntoIterator<Item = &'a Bit>,

Builds Bitset from the collection of Bit values.
Maintains the same index order: first Bit item becomes the least significant bit. Read more
Source§

fn replace(&mut self, index: Index<Self>, value: Bit) -> &mut Self

Replaces the bit at index to the value. Returns a mutable reference to self. Read more
Source§

fn combine<Other, Res>(self, other: Other) -> Res
where Other: Bitset, Res: Bitset, Self::Size: Combines<Other::Size, Res::Size> + Smaller<Res::Size>, Other::Size: Smaller<Res::Size>,

Combines two Bitsets to create a bigger one.
If available, you should prefer using Bitset::combine_optimized. Read more
Source§

fn combine_optimized<Other, Res>(self, other: Other) -> Res
where Self: LeftAligned, Other: Bitset + LeftAligned, Res: Bitset + LeftAligned, Self::Size: Combines<Other::Size, Res::Size> + Smaller<Res::Size>, Other::Size: Smaller<Res::Size>,

Combines two Bitsets to create a bigger one. Uses unsafe optimizations. Read more
Source§

fn split<Res1, Res2>(self) -> (Res1, Res2)
where Res1: Bitset, Res2: Bitset, Self::Size: Splits<Res1::Size, Res2::Size>, Res1::Size: Smaller<Self::Size>, Res2::Size: Smaller<Self::Size>,

Splits Bitset into two smaller ones.
If available, you should prefer using Bitset::split_optimized. Read more
Source§

fn split_optimized<Res1, Res2>(self) -> (Res1, Res2)
where Self: LeftAligned, Res1: Bitset + LeftAligned, Res2: Bitset + LeftAligned, Self::Size: Splits<Res1::Size, Res2::Size>, Res1::Size: Smaller<Self::Size>, Res2::Size: Smaller<Self::Size>,

Splits Bitset into two smaller ones. Uses unsafe optimizations. Read more
Source§

fn bits(self) -> impl Iterator<Item = Bit> + DoubleEndedIterator

Returns iterator over bits of the Bitset in Bit representation. Read more
Source§

fn bits_ref( &self, ) -> impl Iterator<Item = BitRef<'_, Self>> + DoubleEndedIterator

Returns iterator over BitRef holding immutable references to bits of the Bitset. Read more
Source§

fn bits_mut( &mut self, ) -> impl Iterator<Item = BitMut<'_, Self>> + DoubleEndedIterator

Returns iterator over BitMut holding mutable references to bits of the Bitset. Read more
Source§

fn ones(&self) -> impl Iterator<Item = Index<Self>> + DoubleEndedIterator

Returns iterator over indeces of the set bits of the Bitset. Read more
Source§

fn zeros(&self) -> impl Iterator<Item = Index<Self>> + DoubleEndedIterator

Returns iterator over indeces of the not set bits of the Bitset. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.