Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

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 3 years have 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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
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?