Skip to main content
Module

x/result_js/mod.ts>and

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

Returns res if the result is Ok, otherwise returns the Err.

Examples

Example 1

import { and } from "https://deno.land/x/result_js/operators/logical.ts";
import { Err, Ok, type Result } from "https://deno.land/x/result_js/spec.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

declare const result: Result<unknown, unknown>;

assertEquals(and(Ok(0), result), result);
assertEquals(and(Err(1), result), Err(1));

Parameters

result: Result<unknown, E>
res: Result<U, E>