Skip to main content
Module

x/result_js/mod.ts>unwrap

Minimum result type port of Rust
Latest
function unwrap
import { unwrap } from "https://deno.land/x/result_js@2.0.0/mod.ts";

Returns the contained Ok value.

Examples

Example 1

import { Ok } from "https://deno.land/x/result_js/spec.ts";
import { unwrap } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(unwrap(Ok(0)), 0);

Example 2

import { Err } from "https://deno.land/x/result_js/spec.ts";
import { unwrap } from "https://deno.land/x/result_js/operators/extract.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";

assertThrows(() => unwrap(Err(1)));

Parameters

result: Result<T, unknown>