quither
A flexible enum-based utility for representing values that may be on the left, right, neither, or both sides.
Highlights
- Provides a generic enum type supporting
Left,Right,Neither, andBothvariants- Supports arbitrary combinations of
Either,Both, andNeither.
- Supports arbitrary combinations of
- Iterator and standard trait support
- (Supposed to) have compatible interfaces with
itertools'sEitherandEitherOrBothtypes. - No-std compatible, can be build without
stdfeatures.
Example
use ;
// You can create values with any combination of variants:
let left = Left;
let right = Right;
let both = Both;
let neither = Neither;
// Pattern matching on Quither
match both
// You can also convert between different variant sets using TryInto:
// For example, convert a Quither to a type with only Neither and Both variants
let neither_or_both: = both.try_into.unwrap;
// Pattern matching works as usual
match neither_or_both
Crate Features
use_std(default: enabled): Enables implementations for std types (e.g., Read, BufRead)itertools(default: disabled): EnablesIntoimpls from and toitertools::Eitheranditertools::EitherOrBoth.