[−][src]Struct insomnia::EnumSet
An efficient set type for enums.
Serialization
The default representation serializes enumsets as an u8
, u16
, u32
, u64
, or u128
,
whichever 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
#[enumset(serialize_deny_unknown)]
annotation to your enum.
You can add a #[enumset(serialize_repr = "u8")]
annotation to your enum to explicitly set
the bit width the EnumSet
is serialized as. This can be used to avoid breaking changes in
certain serialization formats (such as bincode
).
In addition, the #[enumset(serialize_as_list)]
annotation causes the EnumSet
to be
instead serialized as a list. This requires your enum type implement [Serialize
] and
[Deserialize
].
Implementations
impl<T> EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
pub fn new() -> EnumSet<T>
[src]
Returns an empty set.
pub fn only(t: T) -> EnumSet<T>
[src]
Returns a set containing a single value.
pub fn empty() -> EnumSet<T>
[src]
Returns an empty set.
pub fn all() -> EnumSet<T>
[src]
Returns a set with all bits set.
pub fn bit_width() -> u8
[src]
Total number of bits this enumset uses. 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 }
)
pub fn variant_count() -> u8
[src]
The number of valid variants in this enumset.
This is the same as EnumSet::bit_width
except in enums with "sparse" variants.
(e.g. enum Foo { A = 10, B = 20 }
)
pub fn to_bits(&self) -> u128
[src]
Returns the raw bits of this set
pub fn from_bits(bits: u128) -> EnumSet<T>
[src]
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: EnumSet<T>) -> bool
[src]
Checks if this set shares no elements with another.
pub fn is_superset(&self, other: EnumSet<T>) -> bool
[src]
Checks if all elements in another set are in this set.
pub fn is_subset(&self, other: EnumSet<T>) -> bool
[src]
Checks if all elements of this set are in another set.
pub fn union(&self, other: EnumSet<T>) -> EnumSet<T>
[src]
Returns a set containing the union of all elements in both sets.
pub fn intersection(&self, other: EnumSet<T>) -> EnumSet<T>
[src]
Returns a set containing all elements in common with another set.
pub fn difference(&self, other: EnumSet<T>) -> EnumSet<T>
[src]
Returns a set with all elements of the other set removed.
pub fn symmetrical_difference(&self, other: EnumSet<T>) -> EnumSet<T>
[src]
Returns a set with all elements not contained in both sets.
pub fn complement(&self) -> EnumSet<T>
[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: EnumSet<T>)
[src]
Adds all elements in another set to this one.
pub fn remove_all(&mut self, other: EnumSet<T>)
[src]
Removes all values in another set from this one.
pub fn iter(&self) -> EnumSetIter<T>
[src]
Creates an iterator over the values in this set.
Trait Implementations
impl<T, O> BitAnd<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
type Output = EnumSet<T>
The resulting type after applying the &
operator.
fn bitand(self, other: O) -> <EnumSet<T> as BitAnd<O>>::Output
[src]
impl<T, O> BitAndAssign<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
fn bitand_assign(&mut self, rhs: O)
[src]
impl<T, O> BitOr<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
type Output = EnumSet<T>
The resulting type after applying the |
operator.
fn bitor(self, other: O) -> <EnumSet<T> as BitOr<O>>::Output
[src]
impl<T, O> BitOrAssign<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
fn bitor_assign(&mut self, rhs: O)
[src]
impl<T, O> BitXor<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
type Output = EnumSet<T>
The resulting type after applying the ^
operator.
fn bitxor(self, other: O) -> <EnumSet<T> as BitXor<O>>::Output
[src]
impl<T, O> BitXorAssign<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
fn bitxor_assign(&mut self, rhs: O)
[src]
impl<T> Clone for EnumSet<T> where
T: EnumSetType + Clone,
<T as EnumSetTypePrivate>::Repr: Clone,
[src]
T: EnumSetType + Clone,
<T as EnumSetTypePrivate>::Repr: Clone,
impl<T> Copy for EnumSet<T> where
T: EnumSetType + Copy,
<T as EnumSetTypePrivate>::Repr: Copy,
[src]
T: EnumSetType + Copy,
<T as EnumSetTypePrivate>::Repr: Copy,
impl<T> Debug for EnumSet<T> where
T: EnumSetType + Debug,
[src]
T: EnumSetType + Debug,
impl<T> Default for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
impl<T> Eq for EnumSet<T> where
T: EnumSetType + Eq,
<T as EnumSetTypePrivate>::Repr: Eq,
[src]
T: EnumSetType + Eq,
<T as EnumSetTypePrivate>::Repr: Eq,
impl<T> Extend<T> for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
impl<T> From<T> for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
impl<T> FromIterator<T> for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
fn from_iter<I>(iter: I) -> EnumSet<T> where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
impl<T> Hash for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> IntoIterator for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
type Item = T
The type of the elements being iterated over.
type IntoIter = EnumSetIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> <EnumSet<T> as IntoIterator>::IntoIter
[src]
impl<T> Not for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
type Output = EnumSet<T>
The resulting type after applying the !
operator.
fn not(self) -> <EnumSet<T> as Not>::Output
[src]
impl<T> Ord for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
fn cmp(&self, other: &EnumSet<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<EnumSet<LockType>> for LockType
[src]
fn eq(&self, other: &EnumSet<LockType>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> PartialEq<EnumSet<T>> for EnumSet<T> where
T: EnumSetType + PartialEq<T>,
<T as EnumSetTypePrivate>::Repr: PartialEq<<T as EnumSetTypePrivate>::Repr>,
[src]
T: EnumSetType + PartialEq<T>,
<T as EnumSetTypePrivate>::Repr: PartialEq<<T as EnumSetTypePrivate>::Repr>,
impl<T> PartialEq<T> for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
impl<T> PartialOrd<EnumSet<T>> for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
fn partial_cmp(&self, other: &EnumSet<T>) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> StructuralEq for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
impl<T> StructuralPartialEq for EnumSet<T> where
T: EnumSetType,
[src]
T: EnumSetType,
impl<T, O> Sub<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
type Output = EnumSet<T>
The resulting type after applying the -
operator.
fn sub(self, other: O) -> <EnumSet<T> as Sub<O>>::Output
[src]
impl<T, O> SubAssign<O> for EnumSet<T> where
O: Into<EnumSet<T>>,
T: EnumSetType,
[src]
O: Into<EnumSet<T>>,
T: EnumSetType,
fn sub_assign(&mut self, rhs: O)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for EnumSet<T> where
<T as EnumSetTypePrivate>::Repr: RefUnwindSafe,
<T as EnumSetTypePrivate>::Repr: RefUnwindSafe,
impl<T> Send for EnumSet<T> where
<T as EnumSetTypePrivate>::Repr: Send,
<T as EnumSetTypePrivate>::Repr: Send,
impl<T> Sync for EnumSet<T> where
<T as EnumSetTypePrivate>::Repr: Sync,
<T as EnumSetTypePrivate>::Repr: Sync,
impl<T> Unpin for EnumSet<T> where
<T as EnumSetTypePrivate>::Repr: Unpin,
<T as EnumSetTypePrivate>::Repr: Unpin,
impl<T> UnwindSafe for EnumSet<T> where
<T as EnumSetTypePrivate>::Repr: UnwindSafe,
<T as EnumSetTypePrivate>::Repr: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,