A struct which wraps a value and whether said value is "valid".
Gets the value stored within the Optional.
Gets the value stored within the Optional if valid, otherwise returns the given value.
Destroys the contained value.
Whether this instance contains a valid value.
Creates a new empty value.
Wraps value in an optional type.
Option!int positiveOnly(int value) @nogc nothrow { return value >= 0 ? some(value) : none!int(); } auto rval = positiveOnly(4); if (rval) { writeln("Value is positive!"); } else { writeln("Value is negative!"); }
See Implementation
A struct which wraps a value and whether said value is "valid".