Retrieves the front of a range or a default value
Returns an Optional of the front of a range
Takes a unary function that is called on front of range if it is there
1 import std.algorithm: filter; 2 import std.range: iota, takeNone, drop; 3 import optional: some, none; 4 auto evens = 10.iota.filter!"a % 2 == 0".drop(2); 5 assert(evens.withFront!"a" == some(4)); 6 assert(evens.takeNone.maybeFront == none); 7 assert(evens.takeNone.frontOr(100) == 100);
Provides methods for accessing the front of a range