option_either_or
Convert Option<T> into Either<L, T>.
Overview
This crate introduces either_or and either_or_else to Option in order to facilitate
conversions from Option to Either.
It is mainly useful as generalizations of unwrap_or/unwrap_or_else where the provided default
value is of a different type than the Some variant, but both types implement some common trait.
Examples
You can take advantage of Either implementing Display to provide a default value to
Option<String> without allocating another string...
use OptionEitherOr as _;
let x = Some;
let y = x.either_or;
println!;
... or provide defaults to impl Display (or any other trait generically implemented by Either)
in a generic context...
... or even provide defaults to a generic Future, like so:
use ;
use OptionEitherOr;
async
async