Methods |
public
|
__construct(E $err)
|
#
|
public
|
isOk(): bool
Returns true if the result is Ok .
Returns true if the result is Ok .
Implements
|
#
|
public
|
isOkAnd(Closure $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.
Implements
|
#
|
public
|
isErr(): bool
Returns true if the result is Err .
Returns true if the result is Err .
Implements
|
#
|
public
|
isErrAnd(Closure $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.
Implements
|
#
|
public
|
map(Closure $predicate): self<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.
Implements
|
#
|
public
|
mapOr(mixed $default, Closure $predicate): mixed
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.
Implements
|
#
|
public
|
mapOrElse(Closure $default, Closure $predicate): mixed
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.
Implements
|
#
|
public
|
mapErr<F>(Closure(E): F $predicate): self<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.
Implements
|
#
|
public
|
unwrap(): never
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() .
Implements
|
#
|
public
|
unwrapOr<U>(U $default): 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.
Implements
|
#
|
public
|
unwrapOrElse<U>(Closure(E): U $op): U
Returns the contained Ok value or computes it from a closure.
Returns the contained Ok value or computes it from a closure.
Implements
|
#
|
public
|
unwrapErr(): mixed
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.
Implements
|
#
|
public
|
and(Result $res): self<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.
Implements
|
#
|
public
|
andThen(Closure $op): self<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 .
Implements
|
#
|
public
|
or<T, F, R is Result<T, F>>(R $res): R
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.
Implements
|
#
|
public
|
orElse<T, F, R is Result<T, F>>(Closure(E): R $op): R
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.
Implements
|
#
|