Methods |
public
|
isOk(): bool
Returns true if the result is Ok .
Returns true if the result is Ok .
Implemented by
|
#
|
public
|
isOkAnd(Closure(T): bool $predicate): bool
Returns true if the result is Ok and the value inside of it matches a predicate.
Returns true if the result is Ok and the value inside of it matches a predicate.
Implemented by
|
#
|
public
|
isErr(): bool
Returns true if the result is Err .
Returns true if the result is Err .
Implemented by
|
#
|
public
|
isErrAnd(Closure(E): bool $predicate): bool
Returns true if the result is Err and the value inside of it matches a predicate.
Returns true if the result is Err and the value inside of it matches a predicate.
Implemented by
|
#
|
public
|
map<U>(Closure(T): U $predicate): self<U, E>
Maps a Result<T, E> to Result<U, E> by applying a function to a
contained Ok value, leaving an Err value untouched.
Maps a Result<T, E> to Result<U, E> by applying a function to a
contained Ok value, leaving an Err value untouched.
Implemented by
|
#
|
public
|
mapOr<U>(U $default, Closure(T): U $predicate): U
Returns the provided default (if Err ), or applies a function to the contained value
(if Ok ). Arguments passed to Result::mapOr() are eagerly evaluated; if you are passing the result
of a method call, it is recommended to use Result::mapOrElse() , which is lazily
evaluated.
Returns the provided default (if Err ), or applies a function to the contained value
(if Ok ). Arguments passed to Result::mapOr() are eagerly evaluated; if you are passing the result
of a method call, it is recommended to use Result::mapOrElse() , which is lazily
evaluated.
Implemented by
|
#
|
public
|
mapOrElse<U>(Closure(E): U $default, Closure(T): U $predicate): U
Maps a Result<T, E> to U by applying fallback function $default to a contained
Err value, or function $predicate to a contained Ok value. This method can be used to unpack a successful result while handling an error.
Maps a Result<T, E> to U by applying fallback function $default to a contained
Err value, or function $predicate to a contained Ok value. This method can be used to unpack a successful result while handling an error.
Implemented by
|
#
|
public
|
mapErr<F>(Closure(E): F $predicate): self<T, F>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained
Err value, leaving an Ok value untouched. This method can be used to pass through a successful result while handling an error.
Maps a Result<T, E> to Result<T, F> by applying a function to a contained
Err value, leaving an Ok value untouched. This method can be used to pass through a successful result while handling an error.
Implemented by
|
#
|
public
|
unwrap(): T
Returns the contained Ok value. Because this method may throw, its use is generally discouraged. Instead, prefer to
use pattern matching and handle the Err case explicitly, or call Result::unwrapOr() ,
or Result::unwrapOrElse() .
Returns the contained Ok value. Because this method may throw, its use is generally discouraged. Instead, prefer to
use pattern matching and handle the Err case explicitly, or call Result::unwrapOr() ,
or Result::unwrapOrElse() .
Throws
Implemented by
|
#
|
public
|
unwrapOr<U>(U $default): T|U
Returns the contained Ok value or a provided $default . Arguments passed to Result::unwrapOr() are eagerly evaluated; if you are passing
the result of a method call, it is recommended to use Result::unwrapOrElse() ,
which is lazily evaluated.
Returns the contained Ok value or a provided $default . Arguments passed to Result::unwrapOr() are eagerly evaluated; if you are passing
the result of a method call, it is recommended to use Result::unwrapOrElse() ,
which is lazily evaluated.
Implemented by
|
#
|
public
|
unwrapOrElse<U>(Closure(E): U $op): T|U
Returns the contained Ok value or computes it from a closure.
Returns the contained Ok value or computes it from a closure.
Implemented by
|
#
|
public
|
unwrapErr(): E
Returns the contained Err value. Throws if the value is an Ok , with a custom exception message
provided by the Ok ’s value.
Returns the contained Err value. Throws if the value is an Ok , with a custom exception message
provided by the Ok ’s value.
Throws
Implemented by
|
#
|
public
|
and<U>(self<U, E> $res): self<U, E>
Returns $res if the result is Ok , otherwise returns the Err value of self. Arguments passed to Result::and() are eagerly evaluated; if you are passing the
result of a method call, it is recommended to use Result::andThen() , which is
lazily evaluated.
Returns $res if the result is Ok , otherwise returns the Err value of self. Arguments passed to Result::and() are eagerly evaluated; if you are passing the
result of a method call, it is recommended to use Result::andThen() , which is
lazily evaluated.
Implemented by
|
#
|
public
|
andThen<U>(Closure(T): self<U, E> $op): self<U, E>
Calls $op if the result is Ok , otherwise returns the Err value of self. This method can be used for control flow based on Result values. Often used to chain
fallible operations that may return Err .
Calls $op if the result is Ok , otherwise returns the Err value of self. This method can be used for control flow based on Result values. Often used to chain
fallible operations that may return Err .
Implemented by
|
#
|
public
|
or<F>(self<T, F> $res): self<T, F>
Returns $res if the result is Err , otherwise returns the Ok value of self. Arguments passed to Result::or() are eagerly evaluated; if you are passing the
result of a method call, it is recommended to use Result::orElse() , which is
lazily evaluated.
Returns $res if the result is Err , otherwise returns the Ok value of self. Arguments passed to Result::or() are eagerly evaluated; if you are passing the
result of a method call, it is recommended to use Result::orElse() , which is
lazily evaluated.
Implemented by
|
#
|
public
|
orElse<F>(Closure(E): self<T, F> $op): self<T, F>
Calls $op if the result is Err , otherwise returns the Ok value of self. This method can be used for control flow based on result values.
Calls $op if the result is Err , otherwise returns the Ok value of self. This method can be used for control flow based on result values.
Implemented by
|
#
|