4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RustのResultとOptionの変換関数

Posted at
関数 Result<T, E> Option<T>
() -> bool is_okis_err is_someis_none
() -> T unwrapunwrap_or_defaultexpect(&str) unwrapunwrap_or_defaultexpect(&str)
() -> E unwrap_errexpect_err(&str)
(T) -> T unwrap_or unwrap_or
((E) -> T) -> T1 unwrap_or_else unwrap_or_else
((T) -> U) -> Self map map
(U, (T) -> U) -> Self map_or map_or
((E) -> U, (T) -> U) -> Self1 map_or_else map_or_else
((E) -> F) -> Self map_err
(Self) -> Self andor andorxor
((T) -> Self) -> Self and_then and_then
((E) -> Self) -> Self1 or_else or_else
Result<T, E> <-> Option<T> ok ok_or(E)ok_or_else(() -> E)
Result<E, T> <-> Option<T> err
  1. Optionでは(E)は()になる 2 3

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?