xor method

Option<T> xor(
  1. Option<T> other
)

Returns Some if exactly one of this Option and other is Some, otherwise returns None.

Returns:

  • This Option if this Option is Some and other is None.
  • other if this Option is None and other is Some.
  • None otherwise.

See also: Rust: Option::xor()

Implementation

Option<T> xor(Option<T> other) => switch ((this, other)) {
	(Some(), None()) => this,
	(None(), Some()) => other,
	_ => None()
};