Skip to main content
Module

x/result_js/mod.ts>match

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

Pattern matching for result. Match on matcher.Ok if Ok, otherwise match on matcher.Err.

Examples

Example 1

import { Ok, type Result } from "https://deno.land/x/result_js/spec.ts";
import { match } from "https://deno.land/x/result_js/operators/extract.ts";

declare const result: Result<number, unknown>;

match(result, {
 Ok: (value) => value,
 Err: (value) => 500,
});

Parameters

result: Result<T, E>
matcher: Readonly<Matcher<T, E, U>>