pub enum Set {
Range(Vec<i64>),
Strings(Vec<String>),
Tuples(Vec<IndexTuple>),
}Expand description
A finite, ordered index set.
Supports integer ranges, string lists, and arbitrary tuple lists (built via
Set::product / the &a * &b operator, or constructed directly).
Variants§
Implementations§
Source§impl Set
impl Set
Sourcepub fn range<T: PrimInt>(r: Range<T>) -> Self
pub fn range<T: PrimInt>(r: Range<T>) -> Self
Build an integer index set from a range over any primitive integer
type. Accepts Range<i64>, Range<i32>, Range<usize>, etc.
The untyped literal form Set::range(0..5) defaults to i32 and
works without annotation.
§Panics
Panics if either range bound does not fit in i64.
Sourcepub fn from_ints<T, I>(iter: I) -> Selfwhere
T: PrimInt,
I: IntoIterator<Item = T>,
pub fn from_ints<T, I>(iter: I) -> Selfwhere
T: PrimInt,
I: IntoIterator<Item = T>,
Build an integer index set from an iterator of any primitive integer type. Useful when keys are sparse or computed (e.g. only even indices).
§Panics
Panics if any element does not fit in i64.
pub fn strings<I, S>(iter: I) -> Self
Sourcepub fn product(a: &Set, b: &Set) -> Self
pub fn product(a: &Set, b: &Set) -> Self
Cartesian product of two sets. Inner tuple keys are flattened so a
product (a * b) * c yields 3-element tuples, not nested 2-tuples.
Sourcepub fn filter<F>(&self, f: F) -> Self
pub fn filter<F>(&self, f: F) -> Self
Filter keys with a predicate. Preserves the original variant where
possible, filtered Range/Strings stay in their native variant.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Set
impl RefUnwindSafe for Set
impl Send for Set
impl Sync for Set
impl Unpin for Set
impl UnsafeUnpin for Set
impl UnwindSafe for Set
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more