module d_webservice_example.util.algorithm; import d_webservice_example.util.meta : from; auto findFirst(alias pred, InputRange)(InputRange haystack) if (from!"std.range".isInputRange!InputRange) { import optional.optional : toOptional; import std.algorithm.searching : find; import std.range : take; return haystack.find!(pred).take(1).toOptional(); }