pub struct ESet<T: ReprEnum, const SEP: char = '|'>(/* private fields */);
Expand description
An enum set for a fieldless enum T.
Operators
!
: bitwise not|
: bitwise or, or union&
: bitwise and, or intersection^
: bitwise xor, or exclusive or-
: difference,a - b
is equivalent toa ^ (a & b)
+
: alias for union
Operators are not availble to T by default unless T implements Into<ESetderive_eset
.
If the enum implements FromStr
,
this type provides parsing from CSV like syntax with a given SEP
.
You can use a crate like strum
for this type of functionality.
If serde
is enabled, ths type serializes into a CSV like string in
human readable formats and its integer flags representation in
non-human-readable formats.
While this type is perfectly usable, the user should alias this type ASAP with a fixed SEP for better ergonomics.
type Csv<T> = ESet<T, ','>;
This struct does not maintain the invarient that all bits correspond to valid T, instead invalid bits are ignored during iteration and parsing. This makes operations like bitwise not and binary serialization safe to do.
Implementations§
source§impl<T: ReprEnum, const S: char> ESet<T, S>
impl<T: ReprEnum, const S: char> ESet<T, S>
sourcepub fn new_flags<TIter>(item: impl IntoIterator<Item = TIter>) -> Selfwhere
Self: FromIterator<TIter>,
pub fn new_flags<TIter>(item: impl IntoIterator<Item = TIter>) -> Selfwhere Self: FromIterator<TIter>,
Create a new Eset
from an iterator of enums.
sourcepub const fn with_separator<const SEP: char>(self) -> ESet<T, SEP>
pub const fn with_separator<const SEP: char>(self) -> ESet<T, SEP>
Convert a ESet
into one with a different separator.
Trait Implementations§
source§impl<T: ReprEnum, R: Into<Self>, const S: char> AddAssign<R> for ESet<T, S>
impl<T: ReprEnum, R: Into<Self>, const S: char> AddAssign<R> for ESet<T, S>
source§fn add_assign(&mut self, rhs: R)
fn add_assign(&mut self, rhs: R)
+=
operation. Read moresource§impl<T: ReprEnum, R: Into<Self>, const S: char> BitAndAssign<R> for ESet<T, S>
impl<T: ReprEnum, R: Into<Self>, const S: char> BitAndAssign<R> for ESet<T, S>
source§fn bitand_assign(&mut self, rhs: R)
fn bitand_assign(&mut self, rhs: R)
&=
operation. Read moresource§impl<T: ReprEnum, R: Into<Self>, const S: char> BitOrAssign<R> for ESet<T, S>
impl<T: ReprEnum, R: Into<Self>, const S: char> BitOrAssign<R> for ESet<T, S>
source§fn bitor_assign(&mut self, rhs: R)
fn bitor_assign(&mut self, rhs: R)
|=
operation. Read moresource§impl<T: ReprEnum, R: Into<Self>, const S: char> BitXorAssign<R> for ESet<T, S>
impl<T: ReprEnum, R: Into<Self>, const S: char> BitXorAssign<R> for ESet<T, S>
source§fn bitxor_assign(&mut self, rhs: R)
fn bitxor_assign(&mut self, rhs: R)
^=
operation. Read moresource§impl<T: ReprEnum, const S: char> FromIterator<T> for ESet<T, S>
impl<T: ReprEnum, const S: char> FromIterator<T> for ESet<T, S>
source§fn from_iter<A: IntoIterator<Item = T>>(iter: A) -> Self
fn from_iter<A: IntoIterator<Item = T>>(iter: A) -> Self
source§impl<T: ReprEnum, const S: char> PartialEq<ESet<T, S>> for ESet<T, S>
impl<T: ReprEnum, const S: char> PartialEq<ESet<T, S>> for ESet<T, S>
source§impl<T: ReprEnum, const S: char> PartialOrd<ESet<T, S>> for ESet<T, S>
impl<T: ReprEnum, const S: char> PartialOrd<ESet<T, S>> for ESet<T, S>
source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
==
mean equal >
means contains, <
means contained by, otherwise None
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T: ReprEnum, R: Into<Self>, const S: char> SubAssign<R> for ESet<T, S>
impl<T: ReprEnum, R: Into<Self>, const S: char> SubAssign<R> for ESet<T, S>
source§fn sub_assign(&mut self, rhs: R)
fn sub_assign(&mut self, rhs: R)
-=
operation. Read more