xor method
Returns Some if exactly one of this Option and other is Some, otherwise
returns None.
Returns:
- This
Optionif thisOptionis Some andotheris None. otherif thisOptionis None andotheris Some.- None otherwise.
See also:
Rust: Option::xor()
Implementation
Option<T> xor(Option<T> other) {
return switch ((this, other)) {
(Some(), None()) => this,
(None(), Some()) => other,
_ => None(),
};
}