unexpected

Instantiator for Expected from an unexpected value unexpectedValue.

unexpected
(
T
E
)
(
auto ref E unexpectedValue
)

Examples

alias T = string;           // expected type
alias E = byte;

alias Esi = Expected!(T, byte);

// equality checks
assert(Esi("abc") == Esi("abc"));
assert(Esi("abcabc"[0 .. 3]) ==
       Esi("abcabc"[3 .. 6]));

auto x = Esi("abc");
assert(x.hasExpectedValue);
assert(!x.empty);
assert(x.apply!(threeUnderscores) == Esi("___"));

x.popFront();
assert(!x.hasExpectedValue);
assert(x.empty);

auto y = unexpected!(T, byte)(byte.init);
assert(!y.hasExpectedValue);
assert(x.empty);
assert(y.apply!(threeUnderscores) == Esi(Unexpected!byte(byte.init)));

Meta