Methods |
public
|
isSome(): bool
Returns true if the option is a Some value.
Returns true if the option is a Some value.
Implemented by
|
#
|
public
|
isSomeAnd(Closure(T): bool $predicate): bool
Returns true if the option is a Some and the value inside of it matches a predicate.
Returns true if the option is a Some and the value inside of it matches a predicate.
Implemented by
|
#
|
public
|
isNone(): bool
Returns true if the option is a None value.
Returns true if the option is a None value.
Implemented by
|
#
|
public
|
unwrap(): T
Returns the contained Some value, consuming the self value. Because this method may throw, its use is generally discouraged.
Instead, prefer to call Option::unwrapOr() or Option::unwrapOrElse() .
Returns the contained Some value, consuming the self value. Because this method may throw, its use is generally discouraged.
Instead, prefer to call Option::unwrapOr() or Option::unwrapOrElse() .
Throws
Implemented by
|
#
|
public
|
unwrapOr<S>(S $default): S|T
Returns the contained Some value or a provided default. Arguments passed to Option::unwrapOr() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::unwrapOrElse() ,
which is lazily evaluated.
Returns the contained Some value or a provided default. Arguments passed to Option::unwrapOr() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::unwrapOrElse() ,
which is lazily evaluated.
Implemented by
|
#
|
public
|
unwrapOrElse<S>(Closure(): S $default): S|T
Returns the contained Some value or computes it from a closure.
Returns the contained Some value or computes it from a closure.
Implemented by
|
#
|
public
|
map<U>(Closure(T): U $predicate): self<U>
Maps an Option<T> to Option<U> by applying a function to a
contained value (if Some) or returns None (if None).
Maps an Option<T> to Option<U> by applying a function to a
contained value (if Some) or returns None (if None).
Implemented by
|
#
|
public
|
mapOr<U, V>(V $default, Closure(T): U $predicate): U|V
Returns the provided default result (if none), or applies a function
to the contained value (if any). Arguments passed to Option::mapOr() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::mapOrElse() ,
which is lazily evaluated.
Returns the provided default result (if none), or applies a function
to the contained value (if any). Arguments passed to Option::mapOr() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::mapOrElse() ,
which is lazily evaluated.
Implemented by
|
#
|
public
|
mapOrElse<U, V>(Closure(): V $default, Closure(T): U $predicate): U|V
Computes a default function result (if none), or applies a different function
to the contained value (if any).
Computes a default function result (if none), or applies a different function
to the contained value (if any).
Implemented by
|
#
|
public
|
and<U is Option>(U $other): U
Returns None if the option is None, otherwise returns $other . Arguments passed to Option::and() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::andThen() ,
which is lazily evaluated.
Returns None if the option is None, otherwise returns $other . Arguments passed to Option::and() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::andThen() ,
which is lazily evaluated.
Implemented by
|
#
|
public
|
andThen<U is Option>(Closure(T): U $predicate): U
Returns None if the option is None, otherwise calls $other with the wrapped
value and returns the result.
Returns None if the option is None, otherwise calls $other with the wrapped
value and returns the result.
Implemented by
|
#
|
public
|
filter(Closure(T): bool $predicate): self<T>
Returns None if the option is None, otherwise calls $predicate
with the wrapped value and returns:
Some(t) if predicate returns true (where t is the wrapped value), and
None if predicate returns false.
Returns None if the option is None, otherwise calls $predicate
with the wrapped value and returns:
Some(t) if predicate returns true (where t is the wrapped value), and
None if predicate returns false.
Implemented by
|
#
|
public
|
or<S is Option>(S $other): S
Returns the option if it contains a value, otherwise returns $other . Arguments passed to Option::or() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::orElse() ,
which is lazily evaluated.
Returns the option if it contains a value, otherwise returns $other . Arguments passed to Option::or() are eagerly evaluated; if you are
passing the result of a function call, it is recommended to use Option::orElse() ,
which is lazily evaluated.
Implemented by
|
#
|
public
|
orElse<S is Option>(Closure(): S $other): S
Returns the option if it contains a value, otherwise calls
$other and returns the result.
Returns the option if it contains a value, otherwise calls
$other and returns the result.
Implemented by
|
#
|
public
|
xor<S>(self<S> $other): self<S>
Returns Some if exactly one of self , $other is Some, otherwise returns None.
Returns Some if exactly one of self , $other is Some, otherwise returns None.
Implemented by
|
#
|