Is there any alternative to range front that returns a Nullable (i.e. frontAsMonad or frontAsNullable)?
I'm using Vibe.d and Nullable is the standard way to return an optional element:
@safe Nullable!Item getItem(int _id)
{
import std.algorithm : filter;
with (items.filter!(item => item.id == _id))
{
if (empty)
return Nullable!Item.init;
else
return front.nullable;
}
}
Can this code be written as a simple expression? (without having to write helper methods).