1 unstable release
0.1.0 | Apr 8, 2021 |
---|
#1676 in Data structures
97 downloads per month
Used in 2 crates
(via triangulate)
64KB
927 lines
Zot
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:
first
gets the singular element from*::One
or the first element from*::Two
.Zot<T>
returns anOption<T>
, withZot::Zero
returningNone
.second
gets the second element from*::Two
. BothOt<T>
andZot<T>
return anOption<T>
.last
gets the second element from*::Two
or the singular element from*::One
.Zot<T>
returns anOption<T>
,Ot<T>
returns aT
.*_mut
,replace_*
, andtake_*
(Zot
only) variations are also included.
- Some functions which don't have a clear analogue when working with 2 values are not included (e.g.
zip
). map
requires aFnMut
parameter instead ofFnOnce
as the function may need to be called twice.
Dependencies
~165KB