match

Pattern matching for Nullable and Optional types

template match(handlers...)
match
(
T
)
(
auto ref T t
)
if (
__traits(isSame, TemplateOf!T, Nullable) ||
__traits(isSame, TemplateOf!T, Optional)
)
if (
handlers.length <= 2 &&
handlers.length >= 1
)

Members

Functions

match
MatchReturnType!handlers match(T t)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

Optional!int foo = 7;

foo.match!(
    (int value) => true,
    () => false
); // true
immutable Optional!int foo = 7;
immutable Optional!int bar;

// dfmt off
assertTrue(foo.match!(
	(int value) => true, () => false
));

assertFalse(bar.match!(
	(int value) => true, () => false
));
// dfmt on
immutable Nullable!int foo = 7;
immutable Nullable!int bar;

// dfmt off
assertTrue(foo.match!(
	(int value) => true, () => false
));

assertFalse(bar.match!(
	(int value) => true, () => false
));
// dfmt on

Meta