core.res
Results for recoverable errors, with separate success and error payload types.
All modules · Writing docstrings
enum Res[T, E]A successful value Val(T) or a failure Err(E). Use ? to propagate failure.
let result = Res[Int, Str].Err("missing")print(result.is_err())print(result.unwrap_or(0))true0Res.Val
Section titled “Res.Val”Val(T)A successful result.
Res.Err
Section titled “Res.Err”Err(E)A recoverable failure.
Res[@T, @E]
Section titled “Res[@T, @E]”impl Res[@T, @E]Res[@T, @E].unwrap
Section titled “Res[@T, @E].unwrap”func unwrap(self): TReturn the success payload. Stop with an error if this is Err.
Res[@T, @E].unwrap_or
Section titled “Res[@T, @E].unwrap_or”func unwrap_or(self, default: T): TReturn the success payload, or the eagerly evaluated default on failure.
Res[@T, @E].unwrap_err
Section titled “Res[@T, @E].unwrap_err”func unwrap_err(self): EReturn the error payload. Stop with an error if this is Val.
Res[@T, @E].is_val
Section titled “Res[@T, @E].is_val”func is_val(self): BoolWhether this result contains a success value.
Res[@T, @E].is_err
Section titled “Res[@T, @E].is_err”func is_err(self): BoolWhether this result contains an error value.