Struct enumset::EnumSet

source ·
#[repr(transparent)]
pub struct EnumSet<T: EnumSetType> { /* private fields */ }
Expand description

An efficient set type for enums.

It is implemented using a bitset stored using the smallest integer that can fit all bits in the underlying enum. In general, an enum variant with a discriminator of n is stored in the nth least significant bit (corresponding with a mask of, e.g. 1 << enum as u32).

Numeric representation

EnumSet is internally implemented using integer types, and as such can be easily converted from and to numbers.

Each bit of the underlying integer corresponds to at most one particular enum variant. If the corresponding bit for a variant is set, it present in the set. Bits that do not correspond to any variant are always unset.

By default, each enum variant is stored in a bit corresponding to its discriminator. An enum variant with a discriminator of n is stored in the n + 1th least significant bit (corresponding to a mask of e.g. 1 << enum as u32).

Array representation

Sets with more than 128 variants are instead stored with an underlying array of u64s. This is treated as if it was a single large integer. The nth least significant bit of this integer is stored in the n % 64th least significant bit of the n / 64th element in the array.

Serialization

When the serde feature is enabled, EnumSets can be serialized and deserialized using the serde crate. The exact serialization format can be controlled with additional attributes on the enum type. These attributes are valid regardless of whether the serde feature is enabled.

By default, EnumSet is serialized by directly writing out a single integer containing the numeric representation of the bitset. The integer type used is the smallest one that can fit the largest variant in the enum. If no integer type is large enough, instead the EnumSet is serialized as an array of u64s containing the array representation.

The #[enumset(serialize_repr = "…")] attribute can be used to override the representation used. Valid values are as follows:

  • u8, u16, u32, u64, and u128 serialize the type as the corresponding integer type.
  • array serializes the set as an list of u64s corresponding to the array representation.
  • list serializes the set as a list of enum variants. This requires your enum type implement Serialize and Deserialize.
  • map serializes the set as a map of enum variants to booleans. The set contains a value if the boolean is true. This requires your enum type implement Serialize and Deserialize.

The representation used is determined statically at compile time, and there is currently no support for reading different formats with the same deserializer.

By default, unknown bits are ignored and silently removed from the bitset. To override this behavior, you can add a #[enumset(serialize_deny_unknown)] attribute. This will cause deserialization to fail if an invalid bit is set.

FFI, Safety and repr

If an enum type T is annotated with #[enumset(repr = "…")] where is a primitive integer type, then several things happen:

  • T will implement EnumSetTypeWithRepr<Repr = R> in addition to EnumSetType.
  • The EnumSet methods with repr in their name, such as as_repr and from_repr, will be available for EnumSet<T>.
  • The in-memory representation of EnumSet<T> is guaranteed to be R.

That last guarantee makes it sound to send EnumSet<T> across an FFI boundary. For example:

extern "C" {
    // This function is written in C like:
    // uint32_t some_foreign_function(uint32_t set) { … }
    fn some_foreign_function(set: EnumSet<MyEnum>) -> EnumSet<MyEnum>;
}

#[derive(Debug, EnumSetType)]
#[enumset(repr = "u32")]
enum MyEnum { A, B, C }

let set: EnumSet<MyEnum> = enum_set!(MyEnum::A | MyEnum::C);

let new_set: EnumSet<MyEnum> = unsafe { some_foreign_function(set) };
assert_eq!(new_set, enum_set!(MyEnum::C));

When an EnumSet<T> is received via FFI, all bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

Implementations§

source§

impl<T: EnumSetType> EnumSet<T>

source

pub const EMPTY: Self = _

An empty EnumSet.

This is available as a constant for use in constant expressions.

source

pub const ALL: Self = _

An EnumSet containing all valid variants of the enum.

This is available as a constant for use in constant expressions.

source

pub fn new() -> Self

Creates an empty EnumSet.

source

pub fn only(t: T) -> Self

Returns an EnumSet containing a single element.

source

pub fn empty() -> Self

Creates an empty EnumSet.

This is an alias for EnumSet::new.

source

pub fn all() -> Self

Returns an EnumSet containing all valid variants of the enum.

source

pub fn bit_width() -> u32

Total number of bits used by this type. Note that the actual amount of space used is rounded up to the next highest integer type (u8, u16, u32, u64, or u128).

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

source

pub fn variant_count() -> u32

The number of valid variants that this type can contain.

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

source

pub fn len(&self) -> usize

Returns the number of elements in this set.

source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

source

pub fn clear(&mut self)

Removes all elements from the set.

source

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

Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.

source

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

Returns true if the set is a superset of another, i.e., self contains at least all the values in other.

source

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

Returns true if the set is a subset of another, i.e., other contains at least all the values in self.

source

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

Returns a set containing any elements present in either set.

source

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

Returns a set containing every element present in both sets.

source

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

Returns a set containing element present in self but not in other.

source

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

Returns a set containing every element present in either self or other, but is not present in both.

source

pub fn complement(&self) -> Self

Returns a set containing all enum variants not in this set.

source

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

Checks whether this set contains a value.

source

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

Adds a value to this set.

If the set did not have this value present, true is returned.

If the set did have this value present, false is returned.

source

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

Removes a value from this set. Returns whether the value was present in the set.

source

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

Adds all elements in another set to this one.

source

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

Removes all values in another set from this one.

source§

impl<T: EnumSetType + EnumSetTypeWithRepr> EnumSet<T>

source

pub fn as_repr(&self) -> <T as EnumSetTypeWithRepr>::Repr

Returns a T::Repr representing the elements of this set.

Unlike the other as_* methods, this method is zero-cost and guaranteed not to fail, panic or truncate any bits.

In order to use this method, the definition of T must have the #[enumset(repr = "…")] annotation.

source

pub unsafe fn from_repr_unchecked( bits: <T as EnumSetTypeWithRepr>::Repr ) -> Self

Constructs a bitset from a T::Repr without checking for invalid bits.

Unlike the other from_* methods, this method is zero-cost and guaranteed not to fail, panic or truncate any bits, provided the conditions under “Safety” are upheld.

In order to use this method, the definition of T must have the #[enumset(repr = "…")] annotation.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn from_repr(bits: <T as EnumSetTypeWithRepr>::Repr) -> Self

Constructs a bitset from a T::Repr.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

In order to use this method, the definition of T must have the #[enumset(repr = "…")] annotation.

source

pub fn try_from_repr(bits: <T as EnumSetTypeWithRepr>::Repr) -> Option<Self>

Attempts to constructs a bitset from a T::Repr.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

In order to use this method, the definition of T must have the #[enumset(repr = "…")] annotation.

source

pub fn from_repr_truncated(bits: <T as EnumSetTypeWithRepr>::Repr) -> Self

Constructs a bitset from a T::Repr, ignoring invalid variants.

In order to use this method, the definition of T must have the #[enumset(repr = "…")] annotation.

source§

impl<T: EnumSetType> EnumSet<T>

source

pub fn as_u8(&self) -> u8

Returns a u8 representing the elements of this set.

If the underlying bitset will not fit in a u8, this method will panic.

source

pub fn try_as_u8(&self) -> Option<u8>

Tries to return a u8 representing the elements of this set.

If the underlying bitset will not fit in a u8, this method will panic.

source

pub fn as_u8_truncated(&self) -> u8

Returns a truncated u8 representing the elements of this set.

If the underlying bitset will not fit in a u8, this method will truncate any bits that don’t fit.

source

pub fn from_u8(bits: u8) -> Self

Constructs a bitset from a u8.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_u8(bits: u8) -> Option<Self>

Attempts to constructs a bitset from a u8.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_u8_truncated(bits: u8) -> Self

Constructs a bitset from a u8, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_u8_unchecked(bits: u8) -> Self

Constructs a bitset from a u8, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn as_u16(&self) -> u16

Returns a u16 representing the elements of this set.

If the underlying bitset will not fit in a u16, this method will panic.

source

pub fn try_as_u16(&self) -> Option<u16>

Tries to return a u16 representing the elements of this set.

If the underlying bitset will not fit in a u16, this method will panic.

source

pub fn as_u16_truncated(&self) -> u16

Returns a truncated u16 representing the elements of this set.

If the underlying bitset will not fit in a u16, this method will truncate any bits that don’t fit.

source

pub fn from_u16(bits: u16) -> Self

Constructs a bitset from a u16.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_u16(bits: u16) -> Option<Self>

Attempts to constructs a bitset from a u16.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_u16_truncated(bits: u16) -> Self

Constructs a bitset from a u16, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_u16_unchecked(bits: u16) -> Self

Constructs a bitset from a u16, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn as_u32(&self) -> u32

Returns a u32 representing the elements of this set.

If the underlying bitset will not fit in a u32, this method will panic.

source

pub fn try_as_u32(&self) -> Option<u32>

Tries to return a u32 representing the elements of this set.

If the underlying bitset will not fit in a u32, this method will panic.

source

pub fn as_u32_truncated(&self) -> u32

Returns a truncated u32 representing the elements of this set.

If the underlying bitset will not fit in a u32, this method will truncate any bits that don’t fit.

source

pub fn from_u32(bits: u32) -> Self

Constructs a bitset from a u32.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_u32(bits: u32) -> Option<Self>

Attempts to constructs a bitset from a u32.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_u32_truncated(bits: u32) -> Self

Constructs a bitset from a u32, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_u32_unchecked(bits: u32) -> Self

Constructs a bitset from a u32, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn as_u64(&self) -> u64

Returns a u64 representing the elements of this set.

If the underlying bitset will not fit in a u64, this method will panic.

source

pub fn try_as_u64(&self) -> Option<u64>

Tries to return a u64 representing the elements of this set.

If the underlying bitset will not fit in a u64, this method will panic.

source

pub fn as_u64_truncated(&self) -> u64

Returns a truncated u64 representing the elements of this set.

If the underlying bitset will not fit in a u64, this method will truncate any bits that don’t fit.

source

pub fn from_u64(bits: u64) -> Self

Constructs a bitset from a u64.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_u64(bits: u64) -> Option<Self>

Attempts to constructs a bitset from a u64.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_u64_truncated(bits: u64) -> Self

Constructs a bitset from a u64, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_u64_unchecked(bits: u64) -> Self

Constructs a bitset from a u64, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn as_u128(&self) -> u128

Returns a u128 representing the elements of this set.

If the underlying bitset will not fit in a u128, this method will panic.

source

pub fn try_as_u128(&self) -> Option<u128>

Tries to return a u128 representing the elements of this set.

If the underlying bitset will not fit in a u128, this method will panic.

source

pub fn as_u128_truncated(&self) -> u128

Returns a truncated u128 representing the elements of this set.

If the underlying bitset will not fit in a u128, this method will truncate any bits that don’t fit.

source

pub fn from_u128(bits: u128) -> Self

Constructs a bitset from a u128.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_u128(bits: u128) -> Option<Self>

Attempts to constructs a bitset from a u128.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_u128_truncated(bits: u128) -> Self

Constructs a bitset from a u128, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_u128_unchecked(bits: u128) -> Self

Constructs a bitset from a u128, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn as_usize(&self) -> usize

Returns a usize representing the elements of this set.

If the underlying bitset will not fit in a usize, this method will panic.

source

pub fn try_as_usize(&self) -> Option<usize>

Tries to return a usize representing the elements of this set.

If the underlying bitset will not fit in a usize, this method will panic.

source

pub fn as_usize_truncated(&self) -> usize

Returns a truncated usize representing the elements of this set.

If the underlying bitset will not fit in a usize, this method will truncate any bits that don’t fit.

source

pub fn from_usize(bits: usize) -> Self

Constructs a bitset from a usize.

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_usize(bits: usize) -> Option<Self>

Attempts to constructs a bitset from a usize.

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_usize_truncated(bits: usize) -> Self

Constructs a bitset from a usize, ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_usize_unchecked(bits: usize) -> Self

Constructs a bitset from a usize, without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source§

impl<T: EnumSetType> EnumSet<T>

source

pub fn as_array<const O: usize>(&self) -> [u64; O]

Returns an [u64; O] representing the elements of this set.

If the underlying bitset will not fit in a [u64; O], this method will panic.

source

pub fn try_as_array<const O: usize>(&self) -> Option<[u64; O]>

Returns an [u64; O] representing the elements of this set.

If the underlying bitset will not fit in a [u64; O], this method will instead return None.

source

pub fn as_array_truncated<const O: usize>(&self) -> [u64; O]

Returns an [u64; O] representing the elements of this set.

If the underlying bitset will not fit in a [u64; O], this method will truncate any bits that don’t fit.

source

pub fn from_array<const O: usize>(v: [u64; O]) -> Self

Attempts to constructs a bitset from a [u64; O].

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_array<const O: usize>(bits: [u64; O]) -> Option<Self>

Attempts to constructs a bitset from a [u64; O].

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_array_truncated<const O: usize>(bits: [u64; O]) -> Self

Constructs a bitset from a [u64; O], ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_array_unchecked<const O: usize>(bits: [u64; O]) -> Self

Constructs a bitset from a [u64; O], without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source

pub fn to_vec(&self) -> Vec<u64>

Available on crate feature alloc only.

Returns a Vec<u64> representing the elements of this set.

source

pub fn copy_into_slice(&self, data: &mut [u64])

Copies the elements of this set into a &mut [u64].

If the underlying bitset will not fit in the provided slice, this method will panic.

source

pub fn try_copy_into_slice(&self, data: &mut [u64]) -> Option<()>

Copies the elements of this set into a &mut [u64].

If the underlying bitset will not fit in the provided slice, this method will return None. Otherwise, it will return Some(()).

source

pub fn copy_into_slice_truncated(&self, data: &mut [u64])

Copies the elements of this set into a &mut [u64].

If the underlying bitset will not fit in the provided slice, this method will truncate any bits that don’t fit.

source

pub fn from_slice(v: &[u64]) -> Self

Attempts to constructs a bitset from a &[u64].

If a bit that doesn’t correspond to an enum variant is set, this method will panic.

source

pub fn try_from_slice(bits: &[u64]) -> Option<Self>

Attempts to constructs a bitset from a &[u64].

If a bit that doesn’t correspond to an enum variant is set, this method will return None.

source

pub fn from_slice_truncated(bits: &[u64]) -> Self

Constructs a bitset from a &[u64], ignoring bits that do not correspond to a variant.

source

pub unsafe fn from_slice_unchecked(bits: &[u64]) -> Self

Constructs a bitset from a &[u64], without checking for invalid bits.

Safety

All bits in the provided parameter bits that don’t correspond to an enum variant of T must be set to 0. Behavior is undefined if any of these bits are set to 1.

source§

impl<T: EnumSetType> EnumSet<T>

source

pub fn iter(&self) -> EnumSetIter<T>

Iterates the contents of the set in order from the least significant bit to the most significant bit.

Note that iterator invalidation is impossible as the iterator contains a copy of this type, rather than holding a reference to it.

Trait Implementations§

source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitAnd<O> for EnumSet<T>

§

type Output = EnumSet<T>

The resulting type after applying the & operator.
source§

fn bitand(self, other: O) -> Self::Output

Performs the & operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitAndAssign<O> for EnumSet<T>

source§

fn bitand_assign(&mut self, rhs: O)

Performs the &= operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitOr<O> for EnumSet<T>

§

type Output = EnumSet<T>

The resulting type after applying the | operator.
source§

fn bitor(self, other: O) -> Self::Output

Performs the | operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitOrAssign<O> for EnumSet<T>

source§

fn bitor_assign(&mut self, rhs: O)

Performs the |= operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitXor<O> for EnumSet<T>

§

type Output = EnumSet<T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: O) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> BitXorAssign<O> for EnumSet<T>

source§

fn bitxor_assign(&mut self, rhs: O)

Performs the ^= operation. Read more
source§

impl<T: Clone + EnumSetType> Clone for EnumSet<T>
where T::Repr: Clone,

source§

fn clone(&self) -> EnumSet<T>

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: EnumSetType + Debug> Debug for EnumSet<T>

source§

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

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

impl<T: EnumSetType> Default for EnumSet<T>

source§

fn default() -> Self

Returns an empty set.

source§

impl<'de, T: EnumSetType> Deserialize<'de> for EnumSet<T>

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: EnumSetType + Display> Display for EnumSet<T>

source§

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

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

impl<T: EnumSetType> Extend<EnumSet<T>> for EnumSet<T>

source§

fn extend<I: IntoIterator<Item = EnumSet<T>>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: EnumSetType> Extend<T> for EnumSet<T>

source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: EnumSetType> From<T> for EnumSet<T>

source§

fn from(t: T) -> Self

Converts to this type from the input type.
source§

impl<T: EnumSetType> FromIterator<EnumSet<T>> for EnumSet<T>

source§

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

Creates a value from an iterator. Read more
source§

impl<T: EnumSetType> FromIterator<T> for EnumSet<T>

source§

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

Creates a value from an iterator. Read more
source§

impl<T: EnumSetType> Hash for EnumSet<T>

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<T: EnumSetType> IntoIterator for EnumSet<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = EnumSetIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: EnumSetType> Not for EnumSet<T>

§

type Output = EnumSet<T>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<T: EnumSetType> Ord for EnumSet<T>

source§

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

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

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

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

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

impl<T: EnumSetType> PartialEq<T> for EnumSet<T>

source§

fn eq(&self, other: &T) -> 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: PartialEq + EnumSetType> PartialEq for EnumSet<T>
where T::Repr: PartialEq,

source§

fn eq(&self, other: &EnumSet<T>) -> 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: EnumSetType> PartialOrd for EnumSet<T>

source§

fn partial_cmp(&self, other: &Self) -> 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: EnumSetType> Serialize for EnumSet<T>

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> Sub<O> for EnumSet<T>

§

type Output = EnumSet<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: O) -> Self::Output

Performs the - operation. Read more
source§

impl<T: EnumSetType, O: Into<EnumSet<T>>> SubAssign<O> for EnumSet<T>

source§

fn sub_assign(&mut self, rhs: O)

Performs the -= operation. Read more
source§

impl<'a, T: EnumSetType> Sum<&'a EnumSet<T>> for EnumSet<T>

source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<'a, T: EnumSetType> Sum<&'a T> for EnumSet<T>

source§

fn sum<I: Iterator<Item = &'a T>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T: EnumSetType> Sum<T> for EnumSet<T>

source§

fn sum<I: Iterator<Item = T>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T: EnumSetType> Sum for EnumSet<T>

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T: Copy + EnumSetType> Copy for EnumSet<T>
where T::Repr: Copy,

source§

impl<T: Eq + EnumSetType> Eq for EnumSet<T>
where T::Repr: Eq,

source§

impl<T: EnumSetType> StructuralEq for EnumSet<T>

source§

impl<T: EnumSetType> StructuralPartialEq for EnumSet<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for EnumSet<T>
where <T as EnumSetTypePrivate>::Repr: RefUnwindSafe,

§

impl<T> Send for EnumSet<T>
where <T as EnumSetTypePrivate>::Repr: Send,

§

impl<T> Sync for EnumSet<T>
where <T as EnumSetTypePrivate>::Repr: Sync,

§

impl<T> Unpin for EnumSet<T>
where <T as EnumSetTypePrivate>::Repr: Unpin,

§

impl<T> UnwindSafe for EnumSet<T>
where <T as EnumSetTypePrivate>::Repr: UnwindSafe,

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> 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> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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,

§

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§

default 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>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,