#[cfg(not(feature = "full"))]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Combinator {
Map,
Dot,
Filter,
Inspect,
Then,
AndThen,
Or,
OrElse,
MapErr,
Initial,
Chain,
Flatten,
Collect,
Enumerate,
Find,
Fold,
TryFold,
Unzip,
Zip,
Partition,
FilterMap,
FindMap,
UNWRAP,
}
#[cfg(feature = "full")]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Combinator {
Map,
Dot,
Filter,
Inspect,
Then,
AndThen,
Or,
OrElse,
MapErr,
Initial,
All,
Any,
ByRef,
Chain,
Cloned,
Cmp,
Collect,
Copied,
Count,
Cycle,
Enumerate,
Eq,
FilterMap,
Find,
FindMap,
FlatMap,
Flatten,
Fold,
ForEach,
Fuse,
Ge,
Gt,
IsSorted,
IsSortedBy,
IsSortedByKey,
Last,
Le,
Lt,
Max,
MaxBy,
MaxByKey,
Min,
MinBy,
MinByKey,
Ne,
Nth,
PartialCmp,
IsPartitioned,
Partition,
PartitionInPlace,
Peekable,
Position,
Product,
Rev,
Rposition,
Scan,
SizeHint,
Skip,
SkipWhile,
StepBy,
Sum,
Take,
TakeWhile,
TryFold,
TryForEach,
UNWRAP,
Unzip,
Zip,
}
impl ::std::fmt::Display for Combinator {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl Combinator {
pub fn is_process_expr(self) -> bool {
!self.is_err_expr() && !self.is_initial_expr()
}
pub fn is_err_expr(self) -> bool {
matches!(self, Self::Or | Self::OrElse | Self::MapErr)
}
pub fn is_initial_expr(self) -> bool {
matches!(self, Self::Initial)
}
pub fn can_be_wrapper(self) -> bool {
matches!(
self,
Self::Map
| Self::AndThen
| Self::Filter
| Self::Inspect
| Self::FilterMap
| Self::Find
| Self::FindMap
| Self::Partition
| Self::OrElse
| Self::MapErr
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_tests_can_be_wrapper() {
assert!(Combinator::Map.can_be_wrapper());
assert!(Combinator::AndThen.can_be_wrapper());
assert!(Combinator::Filter.can_be_wrapper());
assert!(Combinator::Inspect.can_be_wrapper());
assert!(Combinator::FilterMap.can_be_wrapper());
assert!(Combinator::Find.can_be_wrapper());
assert!(Combinator::FindMap.can_be_wrapper());
assert!(Combinator::Partition.can_be_wrapper());
assert!(Combinator::OrElse.can_be_wrapper());
assert!(Combinator::MapErr.can_be_wrapper());
assert!(!Combinator::Flatten.can_be_wrapper());
assert!(!Combinator::Dot.can_be_wrapper());
assert!(!Combinator::Then.can_be_wrapper());
assert!(!Combinator::Chain.can_be_wrapper());
assert!(!Combinator::Collect.can_be_wrapper());
assert!(!Combinator::Enumerate.can_be_wrapper());
assert!(!Combinator::Fold.can_be_wrapper());
assert!(!Combinator::TryFold.can_be_wrapper());
assert!(!Combinator::Unzip.can_be_wrapper());
assert!(!Combinator::Zip.can_be_wrapper());
assert!(!Combinator::UNWRAP.can_be_wrapper());
}
}