toOptional

Converts a range or Nullable to an optional type

  1. auto toOptional(R range)
  2. auto toOptional(Nullable!T nullable)
    toOptional
    (
    T
    )
    (
    auto inout ref Nullable!T nullable
    )

Parameters

nullable Nullable!T

the Nullable to convert

Return Value

Type: auto

an optional of the element of range or Nullable

Examples

import std.algorithm: map;
import optional;

assert(no!int.map!"a".toOptional == none);
assert(some(1).map!"a".toOptional == some(1));

Meta