Skip to contents

[Stable]

If the provided object is a Failure (in the case of a Result input) or Nothing (in the case of an Option input), then the function will 'panic' and throw an error of class unwrap_fail_panic.

For this reason, use of this function is not generally advised unless you specifically want to crash your R program or throw an error condition.

Instead you are encouraged to handle the "unhappy path" yourself using unwrap_or_default or unwrap_or_else.

Usage

unwrap(x, ...)

Arguments

x

The object to unwrap.

...

Additional optional arguments that may be used by specific methods.

Value

The value wrapped by x if a condition was not thrown as result of a Failure or Nothing value.

See also

Prefer unwrap_or_default() or unwrap_or_else() to explicitly handle the unhappy path. Alternatively, use unwrap_option() to change a Success to a Some and a Failure to a Nothing.

Examples

Success(10) |> unwrap()
#> [1] 10
Success(1:10) |> unwrap()
#>  [1]  1  2  3  4  5  6  7  8  9 10
Success(c(TRUE, TRUE, FALSE)) |> unwrap()
#> [1]  TRUE  TRUE FALSE
if (FALSE) { # \dontrun{
Failure("Ooopsy") |> unwrap()
} # }