Option

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// To inner type
unwrap () -> T
unwrap_or (T) -> T
unwrap_or_else (() -> T) -> T
unwrap_or_default () -> T where T: Default
expect (&str) -> T

//Converting to another type
map ((T) -> U) -> Option<U>
map_or (U, (T) -> U) -> U
map_or_else (() -> U, (T) -> U) -> U

// To Result
ok_or (E) -> Result<T, E>
ok_or_else (() -> E) -> Result<T, E>

//Conditioning
filter ((&T) -> bool) -> Option<T>
and (Option<U>) -> Option<U>
and_then ((T) -> Option<U>) -> Option<U>
or (Option<T>) -> Option<T>
or_else (() -> Option<T>) -> Option<T>
xor (Option<T>) -> Option<T>

Option<&T>

1
2
3
// Cloning inner
cloned () -> Option<T> where T: Clone
copied () -> Option<T> where T: Copy

Option< Option >

1
flatten () -> Option<T>

Option< Result<T, E> >

1
transpose () -> Result<Option<T>, E>

&Option

1
2
3
4
5
6
7
8
// Checking inner
is_some () -> bool
is_none () -> bool

//To inner reference
as_ref () -> Option<&T>
iter () -> Iterator<&T>
as_deref () -> Option<&U>  where T: Deref<Target = U>