orn 0.6.1
A general implementation of the sum type. Meant to be a generic counterpart to tuples.
---
### Cheat Sheet
```rust
use orn::*;
/// Often, the type of iterator is conditional to some input value. Typically,
/// to unify the return type, one would need to implement a custom iterator, but
/// here `orn` types are used instead.
pub fn unify_divergent(array_or_range: bool) -> impl Iterator- {
if array_or_range {
Or2::T0([1u8, 2u8])
} else {
Or2::T1(0u8..10u8)
}
.into_iter()
// The item of the `Or` iterator is `Or`. `Or::into` collapses an `Or` value into a
// specified type.
.map(Or2::into)
}
/// Using the `tn` methods, items of an `Or` value can be retrieved.
pub fn retrieve_dynamically(input: Or3) {
let _a: Option = input.t0();
let _b: Option = input.t1();
let _c: Option<[char; 1]> = input.t2();
}
/// Using the `At` trait, items of an `Or` value can be retrieved
/// generically.
pub fn retrieve_statically(input: Or4) {
let _a: Option = At::<0>::at(input);
let _b: Option = At::<1>::at(input);
let _c: Option = At::<2>::at(input);
let _d: Option = At::<3>::at(input);
}
fn main() {}
```