Enum Option
enum Option<T>
The Option type. See the module level documentation for more.
Variants
-
None No value.
-
Some(T) Some value of type
T.
Implementations
impl<'a, T> Option<&'a Option<T>>
const fn flatten_ref(self: Self) -> Option<&'a T>Converts from
Option<&Option<T>>toOption<&T>.Examples
Basic usage:
let x: = Some; assert_eq!; let x: = Some; assert_eq!; let x: = None; assert_eq!;
impl<'a, T> Option<&'a mut Option<T>>
const fn flatten_ref(self: Self) -> Option<&'a T>Converts from
Option<&mut Option<T>>to&Option<T>.Examples
Basic usage:
let y = &mut Some; let x: = Some; assert_eq!; let y: &mut = &mut None; let x: = Some; assert_eq!; let x: = None; assert_eq!;const fn flatten_mut(self: Self) -> Option<&'a mut T>Converts from
Option<&mut Option<T>>toOption<&mut T>.Examples
Basic usage:
let y: &mut = &mut Some; let x: = Some; assert_eq!; let y: &mut = &mut None; let x: = Some; assert_eq!; let x: = None; assert_eq!;
impl<T> Option<&T>
const fn copied(self: Self) -> Option<T> where T: CopyMaps an
Option<&T>to anOption<T>by copying the contents of the option.Examples
let x = 12; let opt_x = Some; assert_eq!; let copied = opt_x.copied; assert_eq!;fn cloned(self: Self) -> Option<T> where T: CloneMaps an
Option<&T>to anOption<T>by cloning the contents of the option.Examples
let x = 12; let opt_x = Some; assert_eq!; let cloned = opt_x.cloned; assert_eq!;
impl<T> Option<&mut T>
const fn copied(self: Self) -> Option<T> where T: CopyMaps an
Option<&mut T>to anOption<T>by copying the contents of the option.Examples
let mut x = 12; let opt_x = Some; assert_eq!; let copied = opt_x.copied; assert_eq!;fn cloned(self: Self) -> Option<T> where T: CloneMaps an
Option<&mut T>to anOption<T>by cloning the contents of the option.Examples
let mut x = 12; let opt_x = Some; assert_eq!; let cloned = opt_x.cloned; assert_eq!;
impl<T> Option<Option<T>>
const fn flatten(self: Self) -> Option<T>Converts from
Option<Option<T>>toOption<T>.Examples
Basic usage:
let x: = Some; assert_eq!; let x: = Some; assert_eq!; let x: = None; assert_eq!;Flattening only removes one level of nesting at a time:
let x: = Some; assert_eq!; assert_eq!;
impl<T> Option<T>
const fn is_some(self: &Self) -> boolReturns
trueif the option is aSomevalue.Examples
let x: = Some; assert_eq!; let x: = None; assert_eq!;const fn is_some_and<impl [const] FnOnce(T) -> bool + [const] Destruct: ~const FnOnce(T) -> bool>(self: Self, f: impl ~const FnOnce(T) -> bool) -> boolReturns
trueif the option is aSomeand the value inside of it matches a predicate.Examples
let x: = Some; assert_eq!; let x: = Some; assert_eq!; let x: = None; assert_eq!; let x: = Some; assert_eq!; println!;const fn is_none(self: &Self) -> boolReturns
trueif the option is aNonevalue.Examples
let x: = Some; assert_eq!; let x: = None; assert_eq!;const fn is_none_or<impl [const] FnOnce(T) -> bool + [const] Destruct: ~const FnOnce(T) -> bool>(self: Self, f: impl ~const FnOnce(T) -> bool) -> boolReturns
trueif the option is aNoneor the value inside of it matches a predicate.Examples
let x: = Some; assert_eq!; let x: = Some; assert_eq!; let x: = None; assert_eq!; let x: = Some; assert_eq!; println!;const fn as_ref(self: &Self) -> Option<&T>Converts from
&Option<T>toOption<&T>.Examples
Calculates the length of an
Option<String>as anOption<[usize]>without moving theString. Themapmethod takes theselfargument by value, consuming the original, so this technique usesas_refto first take anOptionto a reference to the value inside the original.let text: = Some; // First, cast `Option<String>` to `Option<&String>` with `as_ref`, // then consume *that* with `map`, leaving `text` on the stack. let text_length: = text.as_ref.map; println!;const fn as_mut(self: &mut Self) -> Option<&mut T>Converts from
&mut Option<T>toOption<&mut T>.Examples
let mut x = Some; match x.as_mut assert_eq!;const fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>>const fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>>Converts from
[Pin]<&mut Option<T>>toOption<[Pin]<&mut T>>.const fn as_slice(self: &Self) -> &[T]Returns a slice of the contained value, if any. If this is
None, an empty slice is returned. This can be useful to have a single type of iterator over anOptionor slice.Note: Should you have an
Option<&T>and wish to get a slice ofT, you can unpack it viaopt.map_or(&[], std::slice::from_ref).Examples
assert_eq!;The inverse of this function is (discounting borrowing)
[_]::first:for i inconst fn as_mut_slice(self: &mut Self) -> &mut [T]Returns a mutable slice of the contained value, if any. If this is
None, an empty slice is returned. This can be useful to have a single type of iterator over anOptionor slice.Note: Should you have an
Option<&mut T>instead of a&mut Option<T>, which this method takes, you can obtain a mutable slice viaopt.map_or(&mut [], std::slice::from_mut).Examples
assert_eq!;The result is a mutable slice of zero or one items that points into our original
Option:let mut x = Some; x.as_mut_slice += 1; assert_eq!;The inverse of this method (discounting borrowing) is
[_]::first_mut:assert_eq!const fn expect(self: Self, msg: &str) -> TReturns the contained
Somevalue, consuming theselfvalue.Panics
Panics if the value is a
Nonewith a custom panic message provided bymsg.Examples
let x = Some; assert_eq!;let x: Option<&str> = None; x.expect("fruits are healthy"); // panics with `fruits are healthy`Recommended Message Style
We recommend that
expectmessages are used to describe the reason you expect theOptionshould beSome.# let slice: &[u8] = &[]; let item = slice.get(0) .expect("slice should not be empty");Hint: If you're having trouble remembering how to phrase expect error messages remember to focus on the word "should" as in "env variable should be set by blah" or "the given binary should be available and executable by the current user".
For more detail on expect message styles and the reasoning behind our recommendation please refer to the section on "Common Message Styles" in the
std::errormodule docs.const fn unwrap(self: Self) -> TReturns the contained
Somevalue, consuming theselfvalue.Because this function may panic, its use is generally discouraged. Panics are meant for unrecoverable errors, and may abort the entire program.
Instead, prefer to use pattern matching and handle the
Nonecase explicitly, or callunwrap_or,unwrap_or_else, orunwrap_or_default. In functions returningOption, you can use the?(try) operator.Panics
Panics if the self value equals
None.Examples
let x = Some; assert_eq!;let x: Option<&str> = None; assert_eq!(x.unwrap(), "air"); // failsconst fn unwrap_or(self: Self, default: T) -> T where T:Returns the contained
Somevalue or a provided default.Arguments passed to
unwrap_orare eagerly evaluated; if you are passing the result of a function call, it is recommended to useunwrap_or_else, which is lazily evaluated.Examples
assert_eq!; assert_eq!;const fn unwrap_or_else<F>(self: Self, f: F) -> T where F: ~const FnOnce() -> TReturns the contained
Somevalue or computes it from a closure.Examples
let k = 10; assert_eq!; assert_eq!;const fn unwrap_or_default(self: Self) -> T where T: ~const DefaultReturns the contained
Somevalue or a default.Consumes the
selfargument then, ifSome, returns the contained value, otherwise ifNone, returns the default value for that type.Examples
let x: = None; let y: = Some; assert_eq!; assert_eq!;unsafe const fn unwrap_unchecked(self: Self) -> TReturns the contained
Somevalue, consuming theselfvalue, without checking that the value is notNone.Safety
Calling this method on
Noneis undefined behavior.Examples
let x = Some; assert_eq!;let x: Option<&str> = None; assert_eq!(unsafe { x.unwrap_unchecked() }, "air"); // Undefined behavior!const fn map<U, F>(self: Self, f: F) -> Option<U> where F: ~const FnOnce(T) -> UMaps an
Option<T>toOption<U>by applying a function to a contained value (ifSome) or returnsNone(ifNone).Examples
Calculates the length of an
Option<String>as anOption<[usize]>, consuming the original:let maybe_some_string = Some; // `Option::map` takes self *by value*, consuming `maybe_some_string` let maybe_some_len = maybe_some_string.map; assert_eq!; let x: = None; assert_eq!;const fn inspect<F>(self: Self, f: F) -> Self where F: ~const FnOnce(&T)Calls a function with a reference to the contained value if
Some.Returns the original option.
Examples
let list = vec!; // prints "got: 2" let x = list .get .inspect .expect; // prints nothing list.get.inspect;const fn map_or<U, F>(self: Self, default: U, f: F) -> U where F: ~const FnOnce(T) -> U, U:Returns the provided default result (if none), or applies a function to the contained value (if any).
Arguments passed to
map_orare eagerly evaluated; if you are passing the result of a function call, it is recommended to usemap_or_else, which is lazily evaluated.Examples
let x = Some; assert_eq!; let x: = None; assert_eq!;const fn map_or_else<U, D, F>(self: Self, default: D, f: F) -> U where D: ~const FnOnce() -> U, F: ~const FnOnce(T) -> UComputes a default function result (if none), or applies a different function to the contained value (if any).
Basic examples
let k = 21; let x = Some; assert_eq!; let x: = None; assert_eq!;Handling a Result-based fallback
A somewhat common occurrence when dealing with optional values in combination with [
Result<T, E>] is the case where one wants to invoke a fallible fallback if the option is not present. This example parses a command line argument (if present), or the contents of a file to an integer. However, unlike accessing the command line argument, reading the file is fallible, so it must be wrapped withOk.# fn main() -> Result<(), Box<dyn std::error::Error>> { let v: u64 = std::env::args() .nth(1) .map_or_else(|| std::fs::read_to_string("/etc/someconfig.conf"), Ok)? .parse()?; # Ok(()) # }const fn map_or_default<U, F>(self: Self, f: F) -> U where U: ~const Default, F: ~const FnOnce(T) -> UMaps an
Option<T>to aUby applying functionfto the contained value if the option isSome, otherwise ifNone, returns the default value for the typeU.Examples
let x: = Some; let y: = None; assert_eq!; assert_eq!;const fn ok_or<E>(self: Self, err: E) -> Result<T, E>Transforms the
Option<T>into a [Result<T, E>], mappingSome(v)toOk(v)andNonetoErr(err).Arguments passed to
ok_orare eagerly evaluated; if you are passing the result of a function call, it is recommended to useok_or_else, which is lazily evaluated.Examples
let x = Some; assert_eq!; let x: = None; assert_eq!;const fn ok_or_else<E, F>(self: Self, err: F) -> Result<T, E> where F: ~const FnOnce() -> ETransforms the
Option<T>into a [Result<T, E>], mappingSome(v)toOk(v)andNonetoErr(err()).Examples
let x = Some; assert_eq!; let x: = None; assert_eq!;const fn as_deref(self: &Self) -> Option<&<T as >::Target> where T: ~const DerefConverts from
Option<T>(or&Option<T>) toOption<&T::Target>.Leaves the original Option in-place, creating a new one with a reference to the original one, additionally coercing the contents via
Deref.Examples
let x: = Some; assert_eq!; let x: = None; assert_eq!;const fn as_deref_mut(self: &mut Self) -> Option<&mut <T as >::Target> where T: ~const DerefMutConverts from
Option<T>(or&mut Option<T>) toOption<&mut T::Target>.Leaves the original
Optionin-place, creating a new one containing a mutable reference to the inner type'sDeref::Targettype.Examples
let mut x: = Some; assert_eq!;fn iter(self: &Self) -> Iter<'_, T>Returns an iterator over the possibly contained value.
Examples
let x = Some; assert_eq!; let x: = None; assert_eq!;fn iter_mut(self: &mut Self) -> IterMut<'_, T>Returns a mutable iterator over the possibly contained value.
Examples
let mut x = Some; match x.iter_mut.next assert_eq!; let mut x: = None; assert_eq!;const fn and<U>(self: Self, optb: Option<U>) -> Option<U> where T: , U:Returns
Noneif the option isNone, otherwise returnsoptb.Arguments passed to
andare eagerly evaluated; if you are passing the result of a function call, it is recommended to useand_then, which is lazily evaluated.Examples
let x = Some; let y: = None; assert_eq!; let x: = None; let y = Some; assert_eq!; let x = Some; let y = Some; assert_eq!; let x: = None; let y: = None; assert_eq!;const fn and_then<U, F>(self: Self, f: F) -> Option<U> where F: ~const FnOnce(T) -> Option<U>Returns
Noneif the option isNone, otherwise callsfwith the wrapped value and returns the result.Some languages call this operation flatmap.
Examples
assert_eq!; assert_eq!; // overflowed! assert_eq!;Often used to chain fallible operations that may return
None.let arr_2d = ; let item_0_1 = arr_2d.get.and_then; assert_eq!; let item_2_0 = arr_2d.get.and_then; assert_eq!;const fn filter<P>(self: Self, predicate: P) -> Self where P: ~const FnOnce(&T) -> bool, T:Returns
Noneif the option isNone, otherwise callspredicatewith the wrapped value and returns:Some(t)ifpredicatereturnstrue(wheretis the wrapped value), andNoneifpredicatereturnsfalse.
This function works similar to [
Iterator::filter()]. You can imagine theOption<T>being an iterator over one or zero elements.filter()lets you decide which elements to keep.Examples
assert_eq!; assert_eq!; assert_eq!;const fn or(self: Self, optb: Option<T>) -> Option<T> where T:Returns the option if it contains a value, otherwise returns
optb.Arguments passed to
orare eagerly evaluated; if you are passing the result of a function call, it is recommended to useor_else, which is lazily evaluated.Examples
let x = Some; let y = None; assert_eq!; let x = None; let y = Some; assert_eq!; let x = Some; let y = Some; assert_eq!; let x: = None; let y = None; assert_eq!;const fn or_else<F>(self: Self, f: F) -> Option<T> where F: ~const FnOnce() -> Option<T>, T:Returns the option if it contains a value, otherwise calls
fand returns the result.Examples
assert_eq!; assert_eq!; assert_eq!;const fn xor(self: Self, optb: Option<T>) -> Option<T> where T:Returns
Someif exactly one ofself,optbisSome, otherwise returnsNone.Examples
let x = Some; let y: = None; assert_eq!; let x: = None; let y = Some; assert_eq!; let x = Some; let y = Some; assert_eq!; let x: = None; let y: = None; assert_eq!;const fn insert(self: &mut Self, value: T) -> &mut T where T:Inserts
valueinto the option, then returns a mutable reference to it.If the option already contains a value, the old value is dropped.
See also
Option::get_or_insert, which doesn't update the value if the option already containsSome.Example
let mut opt = None; let val = opt.insert; assert_eq!; assert_eq!; let val = opt.insert; assert_eq!; *val = 3; assert_eq!;fn get_or_insert(self: &mut Self, value: T) -> &mut TInserts
valueinto the option if it isNone, then returns a mutable reference to the contained value.See also
Option::insert, which updates the value even if the option already containsSome.Examples
let mut x = None; assert_eq!;const fn get_or_insert_default(self: &mut Self) -> &mut T where T: ~const DefaultInserts the default value into the option if it is
None, then returns a mutable reference to the contained value.Examples
let mut x = None; assert_eq!;const fn get_or_insert_with<F>(self: &mut Self, f: F) -> &mut T where F: ~const FnOnce() -> T, T:Inserts a value computed from
finto the option if it isNone, then returns a mutable reference to the contained value.Examples
let mut x = None; assert_eq!;const fn take(self: &mut Self) -> Option<T>Takes the value out of the option, leaving a
Nonein its place.Examples
let mut x = Some; let y = x.take; assert_eq!; assert_eq!; let mut x: = None; let y = x.take; assert_eq!; assert_eq!;const fn take_if<P>(self: &mut Self, predicate: P) -> Option<T> where P: ~const FnOnce(&mut T) -> boolTakes the value out of the option, but only if the predicate evaluates to
trueon a mutable reference to the value.In other words, replaces
selfwithNoneif the predicate returnstrue. This method operates similar toOption::takebut conditional.Examples
let mut x = Some; let prev = x.take_if; assert_eq!; assert_eq!; let prev = x.take_if; assert_eq!; assert_eq!;const fn replace(self: &mut Self, value: T) -> Option<T>Replaces the actual value in the option by the value given in parameter, returning the old value if present, leaving a
Somein its place without deinitializing either one.Examples
let mut x = Some; let old = x.replace; assert_eq!; assert_eq!; let mut x = None; let old = x.replace; assert_eq!; assert_eq!;const fn zip<U>(self: Self, other: Option<U>) -> Option<(T, U)> where T: , U:Zips
selfwith anotherOption.If
selfisSome(s)andotherisSome(o), this method returnsSome((s, o)). Otherwise,Noneis returned.Examples
let x = Some; let y = Some; let z = None::; assert_eq!; assert_eq!;const fn zip_with<U, F, R>(self: Self, other: Option<U>, f: F) -> Option<R> where F: ~const FnOnce(T, U) -> R, T: , U:Zips
selfand anotherOptionwith functionf.If
selfisSome(s)andotherisSome(o), this method returnsSome(f(s, o)). Otherwise,Noneis returned.Examples
let x = Some; let y = Some; assert_eq!; assert_eq!;fn reduce<U, R, F>(self: Self, other: Option<U>, f: F) -> Option<R> where T: Into<R>, U: Into<R>, F: FnOnce(T, U) -> RReduces two options into one, using the provided function if both are
Some.If
selfisSome(s)andotherisSome(o), this method returnsSome(f(s, o)). Otherwise, if only one ofselfandotherisSome, that one is returned. If bothselfandotherareNone,Noneis returned.Examples
let s12 = Some; let s17 = Some; let n = None; let f = ; assert_eq!; assert_eq!; assert_eq!; assert_eq!;
impl<T, E> Option<Result<T, E>>
impl<T, U> Option<(T, U)>
fn unzip(self: Self) -> (Option<T>, Option<U>)Unzips an option containing a tuple of two options.
If
selfisSome((a, b))this method returns(Some(a), Some(b)). Otherwise,(None, None)is returned.Examples
let x = Some; let y = None::; assert_eq!; assert_eq!;
impl<T: IntoIterator> Option<T>
fn into_flat_iter<A>(self: Self) -> OptionFlatten<A> where T: IntoIterator<IntoIter = A>Transforms an optional iterator into an iterator.
If
selfisNone, the resulting iterator is empty. Otherwise, an iterator is made from theSomevalue and returned.Examples
let o1 = Some; let o2 = None::; assert_eq!; assert_eq!;
impl<'a, T> From for Option<&'a T>
fn from(o: &'a Option<T>) -> Option<&'a T>Converts from
&Option<T>toOption<&T>.Examples
Converts an
[Option]<String>into an[Option]<[usize]>, preserving the original. Themapmethod takes theselfargument by value, consuming the original, so this technique usesfromto first take anOptionto a reference to the value inside the original.let s: = Some; let o: = Optionfrom.map; println!; assert_eq!;
impl<'a, T> From for Option<&'a mut T>
fn from(o: &'a mut Option<T>) -> Option<&'a mut T>Converts from
&mut Option<T>toOption<&mut T>Examples
let mut s = Some; let o: = Optionfrom; match o assert_eq!;
impl<A, V: FromIterator<A>> FromIterator for Option<V>
fn from_iter<I: IntoIterator<Item = Option<A>>>(iter: I) -> Option<V>Takes each element in the [
Iterator]: if it is [None][Option::None], no further elements are taken, and the [None][Option::None] is returned. Should no [None][Option::None] occur, a container of typeVcontaining the values of eachOptionis returned.Examples
Here is an example which increments every integer in a vector. We use the checked variant of
addthat returnsNonewhen the calculation would result in an overflow.let items = vec!; let res: = items .iter .map .collect; assert_eq!;As you can see, this will return the expected, valid items.
Here is another example that tries to subtract one from another list of integers, this time checking for underflow:
let items = vec!; let res: = items .iter .map .collect; assert_eq!;Since the last element is zero, it would underflow. Thus, the resulting value is
None.Here is a variation on the previous example, showing that no further elements are taken from
iterafter the firstNone.let items = vec!; let mut shared = 0; let res: = items .iter .map .collect; assert_eq!; assert_eq!;Since the third element caused an underflow, no further elements were taken, so the final value of
sharedis 6 (=3 + 2 + 1), not 16.
impl<T> Any for Option<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Option<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Option<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> Clone for Option<T>
fn clone(self: &Self) -> Selffn clone_from(self: &mut Self, source: &Self)
impl<T> CloneToUninit for Option<T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> Default for Option<T>
fn default() -> Option<T>Returns [
None][Option::None].Examples
let opt: = Optiondefault; assert!;
impl<T> Freeze for Option<T>
impl<T> From for Option<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> From for Option<T>
fn from(t: never) -> T
impl<T> From for Option<T>
fn from(val: T) -> Option<T>Moves
valinto a newSome.Examples
let o: = Optionfrom; assert_eq!;
impl<T> FromResidual for Option<T>
fn from_residual(ops::Yeet: ops::Yeet<()>) -> Self
impl<T> FromResidual for Option<T>
fn from_residual(residual: Option<convert::Infallible>) -> Self
impl<T> IntoIterator for Option<T>
fn into_iter(self: Self) -> IntoIter<T>Returns a consuming iterator over the possibly contained value.
Examples
let x = Some; let v: = x.into_iter.collect; assert_eq!; let x = None; let v: = x.into_iter.collect; assert!;
impl<T> RefUnwindSafe for Option<T>
impl<T> Residual for Option<convert::Infallible>
impl<T> Send for Option<T>
impl<T> StructuralPartialEq for Option<T>
impl<T> Sync for Option<T>
impl<T> Try for Option<T>
fn from_output(output: <Self as >::Output) -> Selffn branch(self: Self) -> ControlFlow<<Self as >::Residual, <Self as >::Output>
impl<T> Unpin for Option<T>
impl<T> UnwindSafe for Option<T>
impl<T> UseCloned for Option<T>
impl<T, U> Into for Option<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> Product for Option<T>
fn product<I>(iter: I) -> Option<T> where I: Iterator<Item = Option<U>>Takes each element in the [
Iterator]: if it is aNone, no further elements are taken, and theNoneis returned. Should noNoneoccur, the product of all elements is returned.Examples
This multiplies each number in a vector of strings, if a string could not be parsed the operation returns
None:let nums = vec!; let total: = nums.iter.map.product; assert_eq!; let nums = vec!; let total: = nums.iter.map.product; assert_eq!;
impl<T, U> Sum for Option<T>
fn sum<I>(iter: I) -> Option<T> where I: Iterator<Item = Option<U>>Takes each element in the [
Iterator]: if it is aNone, no further elements are taken, and theNoneis returned. Should noNoneoccur, the sum of all elements is returned.Examples
This sums up the position of the character 'a' in a vector of strings, if a word did not have the character 'a' the operation returns
None:let words = vec!; let total: = words.iter.map.sum; assert_eq!; let words = vec!; let total: = words.iter.map.sum; assert_eq!;
impl<T, U> TryFrom for Option<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Option<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: $crate::fmt::Debug> Debug for Option<T>
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl<T: $crate::hash::Hash> Hash for Option<T>
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl<T: $crate::marker::Copy> Copy for Option<T>
impl<T: CloneFromCell> CloneFromCell for Option<T>
impl<T: ~const $crate::cmp::Eq> Eq for Option<T>
impl<T: ~const Ord> Ord for Option<T>
fn cmp(self: &Self, other: &Self) -> cmp::Ordering
impl<T: ~const PartialEq> PartialEq for Option<T>
fn eq(self: &Self, other: &Self) -> bool
impl<T: ~const PartialOrd> PartialOrd for Option<T>
fn partial_cmp(self: &Self, other: &Self) -> Option<cmp::Ordering>