Provides Option-like enums for working with ordered collections of zero, one, or two items (Zot), or ordered collections of one or two items (Ot).
let zot = Zot::Two("one", "two");
assert_eq!(zot.last(), Some("two"));
let ot = Ot::One("just one");
assert!(ot.is_one());
Most functionality mimics Option with a few exceptions:
- Some new functions relating to the relative positions have been added:
firstgets the singular element from*::Oneor the first element from*::Two.Zot<T>returns anOption<T>, withZot::ZeroreturningNone.secondgets the second element from*::Two. BothOt<T>andZot<T>return anOption<T>.lastgets the second element from*::Twoor the singular element from*::One.Zot<T>returns anOption<T>,Ot<T>returns aT.*_mut,replace_*, andtake_*(Zotonly) variations are also included.
- Some functions which don't have a clear analogue when working with 2 values are not included (e.g.
zip). maprequires aFnMutparameter instead ofFnOnceas the function may need to be called twice.