RustのResultとOptionの変換関数

|関数|`Result<T, E>`|`Option<T>`|
|:---|:---|:---|
|`() -> bool`|[is_ok][]、[is_err][]|[is_some][]、[is_none][]|
|`() -> T`|[unwrap][unwrap_result]、[unwrap_or_default][unwrap_or_default_result]、[expect(&str)][expect_result]|[unwrap][unwrap_option]、[unwrap_or_default][unwrap_or_default_option]、[expect(&str)][expect_option]|
|`() -> E`|[unwrap_err][unwrap_err_result]、[expect_err(&str)][expect_err_result]||
|`(T) -> T`|[unwrap_or][unwrap_or_result]|[unwrap_or][unwrap_or_option]|
|`((E) -> T) -> T`[^1]|[unwrap_or_else][unwrap_or_else_result]|[unwrap_or_else][unwrap_or_else_option]|
|`((T) -> U) -> Self`|[map][map_result]|[map][map_option]|
|`(U, (T) -> U) -> Self`|[map_or][map_or_result]|[map_or][map_or_option]|
|`((E) -> U, (T) -> U) -> Self`[^1]|[map_or_else][map_or_else_result]|[map_or_else][map_or_else_option]|
|`((E) -> F) -> Self`|[map_err][map_err_result]||
|`(Self) -> Self`|[and][and_result]、[or][or_result]|[and][and_option]、[or][or_option]、[xor][xor_option]|
|`((T) -> Self) -> Self`|[and_then][and_then_result]|[and_then][and_then_option]|
|`((E) -> Self) -> Self`[^1]|[or_else][or_else_result]|[or_else][or_else_option]|
|`Result<T, E> <-> Option<T>`|[ok][ok_result]|[ok_or(E)][ok_or_option]、[ok_or_else(() -> E)][ok_or_else_option]|
|`Result<E, T> <-> Option<T>`|[err][err_result]||

<!-- Result リンク -->

[is_ok]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.is_ok
[is_err]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.is_err
[unwrap_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap
[unwrap_or_default_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_or_default
[expect_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.expect
[unwrap_err_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_err
[expect_err_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.expect_err
[unwrap_or_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_or
[unwrap_or_else_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_or_else
[map_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.map
[map_or_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.map_or
[map_or_else_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.map_or_else
[map_err_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.map_err
[and_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.and
[or_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.or
[and_then_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.and_then
[or_else_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.or_else
[ok_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.ok
[err_result]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.err

<!-- Option リンク -->

[is_some]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.is_some
[is_none]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.is_none
[unwrap_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap
[unwrap_or_default_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_or_default
[expect_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.expect
[unwrap_or_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_or
[unwrap_or_else_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_or_else
[map_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.map
[map_or_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.map_or
[map_or_else_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.map_or_else
[and_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.and
[or_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.or
[xor_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.xor
[and_then_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.and_then
[or_else_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.or_else
[ok_or_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.ok_or
[ok_or_else_option]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.ok_or_else

<!-- Option リンク -->

[^1]: Optionでは(E)は()になる