Function maybeFront
Returns an Optional
of the front of a range
auto auto maybeFront(Range)
(
Range range
)
if (from .std .range .isInputRange!Range);
Since
- 0.0.1
Example
assert((int[]) .init .maybeFront .empty == true);
assert([1, 2] .maybeFront .front == 1);
Example
import std .algorithm: filter;
import ddash .utils .optional: some, none, oc;
struct A {
int x;
int f() {
return x;
}
}
assert((A[]) .init .maybeFront .oc .f == none);
assert([A(3), A(5)] .maybeFront .oc .f == some(3));