Crate option_either_or

Crate option_either_or 

Source
Expand description

An extension trait for Option<T> which provides conversion to Either.

Deriving the naming conventions from Option::ok_or and Option::ok_or_else would lead to symmetrical methods: left_or and left_or_else (and analogically for converting Some to Right), but since the purpose of this conversion pattern is to be a generalization of Option::unwrap_or (_else) supporting different types for different branches, whether Some maps to Left or Right is irrelevant. As a result, the OptionEitherOr extension trait provides either_or and either_or_else.

Providing conversions where it matters whether Some is mapped to Left or Right is out of scope of this crate.

Traitsยง

OptionEitherOr
A trait that provides conversion to Either