[][src]Struct big_enum_set::BigEnumSet

pub struct BigEnumSet<T: BigEnumSetType> { /* fields omitted */ }

An efficient set type for enums.

Serialization

The default representation serializes enumsets as an [u8; N], where N is is the smallest that can contain all bits that are part of the set.

Unknown bits are ignored, and are simply dropped. To override this behavior, you can add a #[big_enum_set(serialize_deny_unknown)] annotation to your enum.

You can add a #[big_enum_set(serialize_bytes = "N")] annotation to your enum to explicitly set the number of bytes the BigEnumSet is serialized as. This can be used to avoid breaking changes in certain serialization formats (such as bincode).

In addition, the #[big_enum_set(serialize_as_list)] annotation causes the BigEnumSet to be instead serialized as a list. This requires your enum type implement [Serialize] and [Deserialize].

Methods

impl<T: BigEnumSetType> BigEnumSet<T>[src]

pub const EMPTY: BigEnumSet<T>[src]

Empty set.

pub fn new() -> Self[src]

Returns an empty set.

pub fn only(t: T) -> Self[src]

Returns a set containing a single value.

pub fn empty() -> Self[src]

Returns an empty set.

pub fn all() -> Self[src]

Returns a set with all bits set.

pub fn bit_width() -> u32[src]

Total number of bits this enum set uses. Note that the actual amount of space used is rounded up to the next highest usize.

This is the same as BigEnumSet::variant_count except in enums with "sparse" variants. (e.g. enum Foo { A = 10, B = 20 })

pub fn variant_count() -> u32[src]

The number of valid variants in this enum set.

This is the same as BigEnumSet::bit_width except in enums with "sparse" variants. (e.g. enum Foo { A = 10, B = 20 })

pub fn to_bits(&self) -> &[usize][src]

Returns the raw bits of this set

pub fn from_bits(bits: &[usize]) -> Self[src]

Constructs a bitset from raw bits.

Panics

If bits not in the enum are set.

pub fn len(&self) -> usize[src]

Returns the number of values in this set.

pub fn is_empty(&self) -> bool[src]

Checks if the set is empty.

pub fn clear(&mut self)[src]

Removes all elements from the set.

pub fn is_disjoint(&self, other: Self) -> bool[src]

Checks if this set shares no elements with another.

pub fn is_superset(&self, other: Self) -> bool[src]

Checks if all elements in another set are in this set.

pub fn is_subset(&self, other: Self) -> bool[src]

Checks if all elements of this set are in another set.

pub fn union(&self, other: Self) -> Self[src]

Returns a set containing the union of all elements in both sets.

pub fn intersection(&self, other: Self) -> Self[src]

Returns a set containing all elements in common with another set.

pub fn difference(&self, other: Self) -> Self[src]

Returns a set with all elements of the other set removed.

pub fn symmetrical_difference(&self, other: Self) -> Self[src]

Returns a set with all elements not contained in both sets.

pub fn complement(&self) -> Self[src]

Returns a set containing all elements not in this set.

pub fn contains(&self, value: T) -> bool[src]

Checks whether this set contains a value.

pub fn insert(&mut self, value: T) -> bool[src]

Adds a value to this set.

pub fn remove(&mut self, value: T) -> bool[src]

Removes a value from this set.

pub fn insert_all(&mut self, other: Self)[src]

Adds all elements in another set to this one.

pub fn remove_all(&mut self, other: Self)[src]

Removes all values in another set from this one.

Important traits for EnumSetIter<T>
pub fn iter(&self) -> EnumSetIter<T>[src]

Creates an iterator over the values in this set.

Trait Implementations

impl<T: BigEnumSetType> From<T> for BigEnumSet<T>[src]

impl<T: PartialEq + BigEnumSetType> PartialEq<BigEnumSet<T>> for BigEnumSet<T> where
    T::Repr: PartialEq
[src]

impl<T: BigEnumSetType> PartialEq<T> for BigEnumSet<T>[src]

impl<T: Eq + BigEnumSetType> Eq for BigEnumSet<T> where
    T::Repr: Eq
[src]

impl<T: Ord + BigEnumSetType> Ord for BigEnumSet<T> where
    T::Repr: Ord
[src]

impl<T: PartialOrd + BigEnumSetType> PartialOrd<BigEnumSet<T>> for BigEnumSet<T> where
    T::Repr: PartialOrd
[src]

impl<T: Hash + BigEnumSetType> Hash for BigEnumSet<T> where
    T::Repr: Hash
[src]

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> Sub<O> for BigEnumSet<T>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> SubAssign<O> for BigEnumSet<T>[src]

impl<T: BigEnumSetType> Not for BigEnumSet<T>[src]

type Output = Self

The resulting type after applying the ! operator.

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitAnd<O> for BigEnumSet<T>[src]

type Output = Self

The resulting type after applying the & operator.

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitOr<O> for BigEnumSet<T>[src]

type Output = Self

The resulting type after applying the | operator.

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitXor<O> for BigEnumSet<T>[src]

type Output = Self

The resulting type after applying the ^ operator.

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitAndAssign<O> for BigEnumSet<T>[src]

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitOrAssign<O> for BigEnumSet<T>[src]

impl<T: BigEnumSetType, O: Into<BigEnumSet<T>>> BitXorAssign<O> for BigEnumSet<T>[src]

impl<T: BigEnumSetType + Debug> Debug for BigEnumSet<T>[src]

impl<T: BigEnumSetType> FromIterator<T> for BigEnumSet<T>[src]

impl<T: Copy + BigEnumSetType> Copy for BigEnumSet<T> where
    T::Repr: Copy
[src]

impl<T: BigEnumSetType> IntoIterator for BigEnumSet<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = EnumSetIter<T>

Which kind of iterator are we turning this into?

impl<T: BigEnumSetType> Extend<T> for BigEnumSet<T>[src]

impl<T: Clone + BigEnumSetType> Clone for BigEnumSet<T> where
    T::Repr: Clone
[src]

impl<T: BigEnumSetType> Default for BigEnumSet<T>[src]

fn default() -> Self[src]

Returns an empty set.

Auto Trait Implementations

impl<T> Unpin for BigEnumSet<T> where
    <T as EnumSetTypePrivate>::Repr: Unpin

impl<T> Send for BigEnumSet<T> where
    <T as EnumSetTypePrivate>::Repr: Send

impl<T> Sync for BigEnumSet<T> where
    <T as EnumSetTypePrivate>::Repr: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]