| Crates.io | quither |
| lib.rs | quither |
| version | 0.7.0 |
| created_at | 2025-05-10 03:37:26.816397+00 |
| updated_at | 2025-06-30 07:23:39.192063+00 |
| description | A flexible enum-based utility for representing values that may be on the left, right, neither, or both sides. |
| homepage | |
| repository | https://github.com/wada314/quither |
| max_upload_size | |
| id | 1668041 |
| size | 131,787 |
A flexible enum-based utility for representing values that may be on the left, right, neither, or both sides.
Left, Right, Neither, and Both variants
Either, Both, and Neither.itertools's Either and EitherOrBoth types.itertools's Either and EitherOrBoth types.map methods, like try_map() or try_map_left().Either to EitherOrBoth is infallible.EitherOrBoth to Either is fallible, where the error type returns the remaining variant type (Both in this case).std features.Result<impl IntoIterator, E> type into impl Iterator<Item = Result<T, E>> type.use quither::{Quither, NeitherOrBoth, EitherOrBoth};
// You can create values with any combination of variants:
let left: Quither<i32, i32> = Quither::Left(1);
let right: Quither<i32, i32> = Quither::Right(2);
let both: Quither<i32, i32> = Quither::Both(1, 2);
let neither = Neither::Neither;
let left2: EitherOrBoth<i32, i32> = EitherOrBoth::Left(1);
// Pattern matching on Quither
match both {
Quither::Left(l) => println!("Left: {}", l),
Quither::Right(r) => println!("Right: {}", r),
Quither::Both(l, r) => println!("Both: {}, {}", l, r),
Quither::Neither => println!("Neither"),
}
// You can convert the type to a "larger" type
let left2_in_quither: Quither<_, _> = left2.into();
// You can also convert into a "smaller" type with fallible conversion.
// For example, convert a Quither to a type with only Neither and Both variants
let neither_or_both: NeitherOrBoth<_, _> = both.try_into().unwrap();
// Pattern matching works as usual
match neither_or_both {
NeitherOrBoth::Both(l, r) => println!("Both: {}, {}", l, r),
NeitherOrBoth::Neither => println!("Neither"),
}
use_std (default: enabled): Enables implementations for std types (e.g., Read, BufRead)itertools (default: disabled): Enables Into impls from and to itertools::Either and itertools::EitherOrBoth.