Skip to main content
Module

x/optio/mod.ts>and

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

Returns None if the option is None, otherwise returns optb.

Examples

Example 1

import { and } from "https://deno.land/x/optio/operators/logical.ts";
import { None, Some } from "https://deno.land/x/optio/spec.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

declare const some: Some<unknown>;
declare const someb: Some<unknown>;

assertEquals(and(some, None), None);
assertEquals(and(some, someb), someb);
assertEquals(and(None, some), None);
assertEquals(and(None, None), None);

Parameters

option: Option<unknown>
optb: Option<T>