Module ddash.range.front

Provides methods for accessing the front of a range

Example

import std.algorithm: filter;
import std.range: iota, takeNone, drop;
import ddash.utils.optional: some, none;
auto evens = 10.iota.filter!"a % 2 == 0".drop(2);
assert(evens.withFront!"a" == some(4));
assert(evens.takeNone.maybeFront == none);
assert(evens.takeNone.frontOr(100) == 100);

Functions

NameDescription
maybeFront(range) Returns an Optional of the front of a range
withFront(range) Takes a unary function that is called on front of range if it is there

Aliases

NameTypeDescription
frontOr Retrieves the front of a range or a default value
frontOrThrow Retrieves the front of a range or throws