Struct bittle::Set

source ·
#[repr(transparent)]
pub struct Set<T, E = DefaultEndian>where T: ?Sized,{ /* private fields */ }
Expand description

Convenience wrapper around bitsets providing the wrapped type with behaviors you’d expected out of a set-like container.


Persistent endianness

A set can be constructed with a custom endianness that it remembers, so that methods such as Bits::iter_ones uses the endianness in the type.

use bittle::{Bits, Set, LittleEndian};

let set: Set<u16> = bittle::set![1, 12];
assert!(set.iter_ones().eq([1, 12]));
assert_eq!(set.into_bits(), 0b00010000_00000010);

let set: Set<u16, LittleEndian> = bittle::set![1, 12];
assert!(set.iter_ones().eq([1, 12]));
assert_eq!(set.into_bits(), 0b01000000_00001000);

Debugging

A reason one might want to use this wrapper is to have a Debug implementation which shows which bits are actually in use:

use bittle::{Bits, Set, LittleEndian};

let set: u128 = bittle::set![1, 14];
assert_eq!(format!("{set:?}"), "16386");

let set: Set<u128> = Set::new(set);
assert_eq!(format!("{set:?}"), "{1, 14}");

let set: u128 = bittle::set_le![1, 14];
assert_eq!(format!("{set:?}"), "85080976323951685521100712850600493056");

let set: Set<u128, LittleEndian> = Set::new_le(set);
assert_eq!(format!("{set:?}"), "{1, 14}");

Standard iteration

This wrapper provides unambigious implementations of IntoIterator which delegates to Bits::iter_ones, avoiding potential confusion when using an array as a set:

use bittle::Set;

let array = [0b00001000u8, 0b0u8];
assert!(array.into_iter().eq([8, 0]));

let set = Set::new(array);
assert!(set.into_iter().eq([3]));

Standard operators

Wrapping into a Set also provides us with BitOr, BitAnd, BitXor, Sub, and BitOrAssign, BitAndAssign, BitXorAssign, SubAssign implementations to work with. They each refer to BitsOwned::union, BitsOwned::conjunction, BitsOwned::symmetric_difference, and BitsOwned::difference respectively.

use bittle::{Bits, Set};

let set1: Set<[u32; 4]> = bittle::set![1, 65];
let set2: Set<[u32; 4]> = bittle::set![65, 110];

assert!((set1 | set2).iter_ones().eq([1, 65, 110]));
assert!((set1 & set2).iter_ones().eq([65]));
assert!((set1 ^ set2).iter_ones().eq([1, 110]));
assert!((set1 - set2).iter_ones().eq([1]));

let mut set3 = set1.clone();
set3 |= &set2;
assert!(set3.iter_ones().eq([1, 65, 110]));

let mut set3 = set1.clone();
set3 &= &set2;
assert!(set3.iter_ones().eq([65]));

let mut set3 = set1.clone();
set3 ^= &set2;
assert!(set3.iter_ones().eq([1, 110]));

let mut set3 = set1.clone();
set3 -= &set2;
assert!(set3.iter_ones().eq([1]));

Equality and comparison

It also ensures that for operations that can be, are generic over bitwise indexes, allowing different kinds of bitsets to be compared:

use bittle::Set;
let a = 0b00000000_00000000_00000001_00010000u32;
let b = 0b00000001_00010000u16;
let c = vec![0b00010000u8, 0b00000001u8];

assert_eq!(Set::new(a), Set::new(b));
assert_eq!(Set::new(a), Set::from_ref(&c[..]));

let d = 0b00000001_11111111u16;
assert!(Set::new(d) < Set::new(a));
assert!(Set::new(d) < Set::new(b));
assert!(Set::new(d) < Set::from_ref(&c[..]));

Note that if this result seems peculiar to you, consider that a bitset is actually an ordered set, so it would mimic the behavior of BTreeSet<u32> where u32 are the indexes in the set rather than a direct numerical comparison:

use std::collections::BTreeSet;
let mut a = BTreeSet::new();
let mut b = BTreeSet::new();

a.insert(0u32);
a.insert(1u32);
b.insert(1u32);

assert!(a < b);

More Examples

use bittle::{Bits, BitsMut, BitsOwned, Set};

let mut a = Set::<u128>::zeros();

assert!(!a.test_bit(1));
a.set_bit(1);
assert!(a.test_bit(1));
a.clear_bit(1);
assert!(!a.test_bit(1));

The bit set can also use arrays as its backing storage.

use bittle::{Bits, BitsMut, BitsOwned, Set};

let mut a = Set::<[u64; 16]>::zeros();

assert!(!a.test_bit(172));
a.set_bit(172);
assert!(a.test_bit(172));
a.clear_bit(172);
assert!(!a.test_bit(172));

We can use the iterator of each set to compare bit sets of different kinds:

use bittle::{Bits, BitsMut, BitsOwned, Set};

let mut a = Set::<[u64; 2]>::zeros();
let mut b = Set::<u128>::zeros();

a.set_bit(111);
assert!(!a.iter_ones().eq(b.iter_ones()));

b.set_bit(111);
assert!(a.iter_ones().eq(b.iter_ones()));

Implementations§

source§

impl<T> Set<T>

source

pub const fn new(bits: T) -> Self

Construct a set from its underlying bits using DefaultEndian.

Examples
use bittle::{Bits, Set};

let mut set = Set::new(0b00001001u32);
assert!(set.iter_ones().eq([0, 3]));
source§

impl<T> Set<T, LittleEndian>

source

pub const fn new_le(bits: T) -> Self

Construct a set from its underlying bits using LittleEndian indexing.

Examples
use bittle::{Bits, Set};

let mut set = Set::new_le(0b00001001u8);
assert!(set.iter_ones().eq([4, 7]));
source§

impl<T, E> Set<T, E>

source

pub const fn new_in(bits: T) -> Self

Construct a set from its underlying bits using custom endianness.

Examples
use bittle::{Bits, Set, LittleEndian};

let mut set: Set<u8, LittleEndian> = Set::new_in(0b00001001u8);
assert!(set.iter_ones().eq([4, 7]));
assert!(set.iter_ones_in::<LittleEndian>().eq([4, 7]));
source

pub fn into_bits(self) -> T

Coerce into raw interior bits.

Examples
use bittle::{Bits, Set};

let mut set = Set::new(0b00001001u8);
assert_eq!(set.into_bits(), 0b00001001u8);

let mut set = Set::new_le(0b00001001u8);
assert_eq!(set.into_bits(), 0b00001001u8);
source§

impl<T> Set<T>where T: ?Sized,

source

pub fn from_ref<U>(bits: &U) -> &Selfwhere U: ?Sized + AsRef<T>,

Wrap a reference as a set using DefaultEndian indexing.

Examples
use bittle::{Bits, Set};

let mut set = Set::from_ref(&[0b00000001u8, 0b00010000u8]);
assert!(set.iter_ones().eq([0, 12]));
source

pub fn from_mut<U>(bits: &mut U) -> &mut Selfwhere U: ?Sized + AsMut<T>,

Wrap a mutable reference as a set using DefaultEndian indexing.

Examples
use bittle::{Bits, BitsMut, Set};

let mut values = [0b00000001u8, 0b00010000u8];

let mut set = Set::from_mut(&mut values);
assert!(set.iter_ones().eq([0, 12]));

set.set_bit(4);
assert_eq!(&values[..], &[0b00010001u8, 0b00010000u8]);
source§

impl<T> Set<T, LittleEndian>where T: ?Sized,

source

pub fn from_ref_le<U>(bits: &U) -> &Selfwhere U: ?Sized + AsRef<T>,

Wrap a reference as a set using LittleEndian indexing.

Examples
use bittle::{Bits, Set};

let mut set = Set::from_ref_le(&[0b00000001u8, 0b00010000u8]);
assert!(set.iter_ones_le().eq([7, 11]));
source

pub fn from_mut_le<U>(bits: &mut U) -> &mut Selfwhere U: ?Sized + AsMut<T>,

Wrap a mutable reference as a set using LittleEndian indexing.

Examples
use bittle::{Bits, BitsMut, Set, LittleEndian};

let mut values = [0b00000001u8, 0b00010000u8];

let mut set = Set::from_mut_le(&mut values);
assert!(set.iter_ones_le().eq([7, 11]));

set.set_bit(4);
assert_eq!(&values[..], &[0b00001001u8, 0b00010000u8]);

Trait Implementations§

source§

impl<T, E> BitAnd<&Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Set<T, E>) -> Self::Output

Performs the & operation. Read more
source§

impl<T, E> BitAnd<&Set<T, E>> for Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Set<T, E>) -> Self::Output

Performs the & operation. Read more
source§

impl<T, E> BitAnd<Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Set<T, E>) -> Self::Output

Performs the & operation. Read more
source§

impl<T, E> BitAnd<Set<T, E>> for Set<T, E>where T: BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Set<T, E>) -> Self::Output

Performs the & operation. Read more
source§

impl<T, E> BitAndAssign<&Set<T, E>> for &mut Set<T, E>where T: BitsMut,

source§

fn bitand_assign(&mut self, rhs: &Set<T, E>)

Performs the &= operation. Read more
source§

impl<T, E> BitAndAssign<&Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitand_assign(&mut self, rhs: &Set<T, E>)

Performs the &= operation. Read more
source§

impl<T, E> BitAndAssign<Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitand_assign(&mut self, rhs: Set<T, E>)

Performs the &= operation. Read more
source§

impl<T, E> BitOr<&Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Set<T, E>) -> Self::Output

Performs the | operation. Read more
source§

impl<T, E> BitOr<&Set<T, E>> for Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: &Set<T, E>) -> Self::Output

Performs the | operation. Read more
source§

impl<T, E> BitOr<Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Set<T, E>) -> Self::Output

Performs the | operation. Read more
source§

impl<T, E> BitOr<Set<T, E>> for Set<T, E>where T: BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Set<T, E>) -> Self::Output

Performs the | operation. Read more
source§

impl<T, E> BitOrAssign<&Set<T, E>> for &mut Set<T, E>where T: BitsMut,

source§

fn bitor_assign(&mut self, rhs: &Set<T, E>)

Performs the |= operation. Read more
source§

impl<T, E> BitOrAssign<&Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitor_assign(&mut self, rhs: &Set<T, E>)

Performs the |= operation. Read more
source§

impl<T, E> BitOrAssign<Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitor_assign(&mut self, rhs: Set<T, E>)

Performs the |= operation. Read more
source§

impl<T, E> BitXor<&Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Set<T, E>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T, E> BitXor<&Set<T, E>> for Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: &Set<T, E>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T, E> BitXor<Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Set<T, E>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T, E> BitXor<Set<T, E>> for Set<T, E>where T: BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Set<T, E>) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T, E> BitXorAssign<&Set<T, E>> for &mut Set<T, E>where T: BitsMut,

source§

fn bitxor_assign(&mut self, rhs: &Set<T, E>)

Performs the ^= operation. Read more
source§

impl<T, E> BitXorAssign<&Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitxor_assign(&mut self, rhs: &Set<T, E>)

Performs the ^= operation. Read more
source§

impl<T, E> BitXorAssign<Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn bitxor_assign(&mut self, rhs: Set<T, E>)

Performs the ^= operation. Read more
source§

impl<T, U> Bits for Set<T, U>where T: ?Sized + Bits, U: Endian,

§

type IterOnes<'a> where Self: 'a = <T as Bits>::IterOnesIn<'a, U>

The iterator over zeros in this bit pattern using DefaultEndian indexing. Read more
§

type IterOnesIn<'a, E> where Self: 'a, E: Endian = <T as Bits>::IterOnesIn<'a, E>

The iterator over ones in this bit pattern using custom Endian indexing. Read more
§

type IterZeros<'a> where Self: 'a = <T as Bits>::IterZerosIn<'a, U>

The iterator over zeros in this bit pattern using DefaultEndian indexing. Read more
§

type IterZerosIn<'a, E> where Self: 'a, E: Endian = <T as Bits>::IterZerosIn<'a, E>

The iterator over zeros in this bit pattern using custom Endian indexing. Read more
source§

fn count_ones(&self) -> u32

Get the number of ones in the set. Read more
source§

fn count_zeros(&self) -> u32

Get the number of ones in the set. Read more
source§

fn bits_capacity(&self) -> u32

Get the capacity of the underlying set. Read more
source§

fn all_ones(&self) -> bool

Test if bit set is full, or all ones. Read more
source§

fn all_zeros(&self) -> bool

Test if this set is empty, or all zeros. Read more
source§

fn test_bit(&self, index: u32) -> bool

Test if the given bit is set using DefaultEndian indexing. Read more
source§

fn test_bit_in<E>(&self, index: u32) -> boolwhere E: Endian,

Test if the given bit is set using custom Endian indexing. Read more
source§

fn iter_ones(&self) -> Self::IterOnes<'_>

Construct an iterator over ones in the bit set using DefaultEndian indexing. Read more
source§

fn iter_ones_in<E>(&self) -> Self::IterOnesIn<'_, E>where E: Endian,

Construct an iterator over ones in the bit set. Read more
source§

fn iter_zeros(&self) -> Self::IterZeros<'_>

Construct an iterator over zeros in the bit set using DefaultEndian indexing. Read more
source§

fn iter_zeros_in<E>(&self) -> Self::IterZerosIn<'_, E>where E: Endian,

Construct an iterator over zeros in the bit set. Read more
source§

fn test_bit_le(&self, index: u32) -> bool

Test if the given bit is set using LittleEndian indexing. Read more
source§

fn test_bit_be(&self, index: u32) -> bool

Test if the given bit is set using BigEndian indexing. Read more
source§

fn iter_ones_le(&self) -> Self::IterOnesIn<'_, LittleEndian>

Construct an iterator over ones in the bit set using LittleEndian indexing. Read more
source§

fn iter_ones_be(&self) -> Self::IterOnesIn<'_, BigEndian>

Construct an iterator over ones in the bit set using BigEndian indexing. Read more
source§

fn iter_zeros_le(&self) -> Self::IterZerosIn<'_, LittleEndian>

Construct an iterator over zeros in the bit set using LittleEndian indexing. Read more
source§

fn iter_zeros_be(&self) -> Self::IterZerosIn<'_, BigEndian>

Construct an iterator over zeros in the bit set using BigEndian indexing. Read more
source§

impl<T, U> BitsMut for Set<T, U>where T: ?Sized + BitsMut, U: Endian,

source§

fn set_bit_in<E>(&mut self, index: u32)where E: Endian,

Set the given bit. Read more
source§

fn set_bit(&mut self, index: u32)

Set the given bit using DefaultEndian. Read more
source§

fn clear_bit_in<E>(&mut self, index: u32)where E: Endian,

Clear the given bit with a custom Endian indexing. Read more
source§

fn clear_bit(&mut self, index: u32)

Clear the given bit using DefaultEndian. Read more
source§

fn clear_bits(&mut self)

Clear the entire bit pattern. Read more
source§

fn union_assign(&mut self, other: &Self)

Modify the current set in place so that it becomes a union of this and another set. Read more
source§

fn conjunction_assign(&mut self, other: &Self)

Modify the current set in place so that it becomes a conjunction of this and another set. Read more
source§

fn difference_assign(&mut self, other: &Self)

Modify the current set in place so that it becomes a difference of this and another set. Read more
source§

fn symmetric_difference_assign(&mut self, other: &Self)

Modify the current set in place so that it becomes a symmetric difference of this and another set. Read more
source§

fn set_bit_le(&mut self, index: u32)

Set the given bit using LittleEndian indexing. Read more
source§

fn set_bit_be(&mut self, index: u32)

Set the given bit using LittleEndian indexing. Read more
source§

fn clear_bit_le(&mut self, index: u32)

Clear the given bit using LittleEndian indexing. Read more
source§

fn clear_bit_be(&mut self, index: u32)

Clear the given bit using BigEndian indexing. Read more
source§

impl<T, U> BitsOwned for Set<T, U>where T: BitsOwned, U: Endian,

source§

const BITS: u32 = T::BITS

The number of bits in the bit set. Read more
source§

const ONES: Self = _

The bit pattern containing all ones, or one that is full. Read more
source§

const ZEROS: Self = _

The bit pattern containing all zeros, or one that is empty. Read more
§

type IntoIterOnes = <T as BitsOwned>::IntoIterOnesIn<U>

Owning iterator over bits set to ones using DefaultEndian indexing. Read more
§

type IntoIterOnesIn<E> where E: Endian = <T as BitsOwned>::IntoIterOnesIn<E>

Owning iterator over bits set to ones using custom Endian indexing. Read more
§

type IntoIterZeros = <T as BitsOwned>::IntoIterZerosIn<U>

Owning iterator over bits set to zero using the DefaultEndian ordering. Read more
§

type IntoIterZerosIn<E> where E: Endian = <T as BitsOwned>::IntoIterZerosIn<E>

Owning iterator over bits set to zero using custom Endian ordering. Read more
source§

fn zeros() -> Self

Construct a bit set of all zeros, or one that is empty. Read more
source§

fn ones() -> Self

Construct a bit set of all ones, or one that is full. Read more
source§

fn with_bit_in<E>(self, bit: u32) -> Selfwhere E: Endian,

Set the given bit and return the modified set. Read more
source§

fn with_bit(self, bit: u32) -> Self

Set the given bit and return the modified set with the DefaultEndian indexing. Read more
source§

fn without_bit_in<E>(self, bit: u32) -> Selfwhere E: Endian,

Set the given bit and return the modified set using custom Endian indexing. Read more
source§

fn without_bit(self, bit: u32) -> Self

Set the given bit and return the modified set using DefaultEndian indexing. Read more
source§

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

Construct the union between this and another set. Read more
source§

fn conjunction(self, other: Self) -> Self

Construct a conjunction of this and another set. Read more
source§

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

Construct the difference between this and another set. Read more
source§

fn symmetric_difference(self, other: Self) -> Self

Construct the symmetric difference between this and another set. Read more
source§

fn into_iter_ones(self) -> Self::IntoIterOnes

Construct an owning iterator over all ones in a set using the DefaultEndian indexing. Read more
source§

fn into_iter_ones_in<E>(self) -> Self::IntoIterOnesIn<E>where E: Endian,

Construct an owning iterator over all ones in a set using custom Endian indexing. Read more
source§

fn into_iter_zeros(self) -> Self::IntoIterZeros

Construct an owning iterator over all zeros in a set using DefaultEndian indexing. Read more
source§

fn into_iter_zeros_in<E>(self) -> Self::IntoIterZerosIn<E>where E: Endian,

Construct an owning iterator over all zeros in a set using custom Endian indexing. Read more
source§

fn with_bit_le(self, bit: u32) -> Selfwhere Self: Sized,

Set the given bit and return the modified set with the LittleEndian indexing. Read more
source§

fn with_bit_be(self, bit: u32) -> Selfwhere Self: Sized,

Set the given bit and return the modified set with the BigEndian indexing. Read more
source§

fn without_bit_le(self, bit: u32) -> Selfwhere Self: Sized,

Set the given bit and return the modified set using LittleEndian indexing. Read more
source§

fn without_bit_be(self, bit: u32) -> Selfwhere Self: Sized,

Set the given bit and return the modified set using BigEndian indexing. Read more
source§

fn into_iter_ones_le(self) -> Self::IntoIterOnesIn<LittleEndian>where Self: Sized,

Construct an owning iterator over all ones in a set using LittleEndian indexing. Read more
source§

fn into_iter_ones_be(self) -> Self::IntoIterOnesIn<BigEndian>where Self: Sized,

Construct an owning iterator over all ones in a set using BigEndian indexing. Read more
source§

fn into_iter_zeros_le(self) -> Self::IntoIterZerosIn<LittleEndian>where Self: Sized,

Construct an owning iterator over all zeros in a set using LittleEndian indexing. Read more
source§

fn into_iter_zeros_be(self) -> Self::IntoIterZerosIn<BigEndian>where Self: Sized,

Construct an owning iterator over all zeros in a set using BigEndian indexing. Read more
source§

impl<T, E> Clone for Set<T, E>where T: Clone,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T, E> Debug for Set<T, E>where T: ?Sized + Bits, E: Endian,

source§

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

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

impl<T, E> Default for Set<T, E>where T: BitsOwned, E: Endian,

source§

fn default() -> Self

Construct a new empty set.

Examples
use bittle::{Bits, BitsMut, BitsOwned, Set};

let mut a = Set::<u32>::zeros();

assert!(a.all_zeros());
a.set_bit(0);
assert!(!a.all_zeros());
source§

impl<T, E> From<T> for Set<T, E>where T: BitsOwned, E: Endian,

source§

fn from(bits: T) -> Self

Converts to this type from the input type.
source§

impl<T, E> Hash for Set<T, E>where T: ?Sized + Hash,

source§

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

Feeds this value into the given Hasher. Read more
source§

impl<'a, T, E> IntoIterator for &'a Set<T, E>where T: ?Sized + Bits, E: Endian,

§

type IntoIter = <T as Bits>::IterOnesIn<'a, E>

Which kind of iterator are we turning this into?
§

type Item = <<&'a Set<T, E> as IntoIterator>::IntoIter as Iterator>::Item

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T, E> IntoIterator for Set<T, E>where T: BitsOwned, E: Endian,

§

type IntoIter = <T as BitsOwned>::IntoIterOnesIn<E>

Which kind of iterator are we turning this into?
§

type Item = <<Set<T, E> as IntoIterator>::IntoIter as Iterator>::Item

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T, E> Ord for Set<T, E>where T: ?Sized + Bits, E: Endian,

source§

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

This method returns an Ordering between self and other. Read more
source§

impl<T, U, E> PartialEq<U> for Set<T, E>where T: ?Sized + Bits, U: ?Sized + Bits, E: Endian,

Flexible PartialEq implementation which allows for comparisons between different kinds of sets.

Examples

use bittle::Set;

let a = Set::new(0b00001000u8);
let b = Set::new(0b00000000_00001000u16);
let c = Set::new([0b00001000u8, 0]);

assert_eq!(a, b);
assert_eq!(a, c);
source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, U, E> PartialOrd<U> for Set<T, E>where T: ?Sized + Bits, U: ?Sized + Bits, E: Endian,

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, E> Sub<&Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Set<T, E>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, E> Sub<&Set<T, E>> for Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Set<T, E>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, E> Sub<Set<T, E>> for &Set<T, E>where T: Copy + BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Set<T, E>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, E> Sub<Set<T, E>> for Set<T, E>where T: BitsOwned, E: Endian,

§

type Output = Set<T, E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Set<T, E>) -> Self::Output

Performs the - operation. Read more
source§

impl<T, E> SubAssign<&Set<T, E>> for &mut Set<T, E>where T: BitsMut,

source§

fn sub_assign(&mut self, rhs: &Set<T, E>)

Performs the -= operation. Read more
source§

impl<T, E> SubAssign<&Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn sub_assign(&mut self, rhs: &Set<T, E>)

Performs the -= operation. Read more
source§

impl<T, E> SubAssign<Set<T, E>> for Set<T, E>where T: BitsMut,

source§

fn sub_assign(&mut self, rhs: Set<T, E>)

Performs the -= operation. Read more
source§

impl<T, E> Copy for Set<T, E>where T: Copy,

source§

impl<T, E> Eq for Set<T, E>where T: ?Sized + Bits, E: Endian,

Auto Trait Implementations§

§

impl<T: ?Sized, E> RefUnwindSafe for Set<T, E>where E: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T: ?Sized, E> Send for Set<T, E>where E: Send, T: Send,

§

impl<T: ?Sized, E> Sync for Set<T, E>where E: Sync, T: Sync,

§

impl<T: ?Sized, E> Unpin for Set<T, E>where E: Unpin, T: Unpin,

§

impl<T: ?Sized, E> UnwindSafe for Set<T, E>where E: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.