auto a = some(7); auto b = none!int; assertEquals(7, a.front); assertTrue(a.defined); a.popFront(); assertFalse(a.defined); expectThrows!AssertError(a.front); expectThrows!AssertError(b.front);
assertTrue(some(5).defined); assertTrue(Optional!int(5).defined); struct foobar { @disable this(this); int z; } assertTrue(some(foobar()).defined); assertTrue(some(none!int).defined); assertFalse(some!int(none).defined); assertFalse(some(null).defined); assertFalse(none!int.defined); assertFalse(Optional!int().defined); assertFalse(Optional!(int[])().defined);
Creates an empty optional type