Skip to main content
Module

x/optio/mod.ts>xor

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

Returns Some if exactly one of option, optb is Some, otherwise returns None.

Examples

Example 1

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

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

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

Parameters

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