13 lines
380 B
D
13 lines
380 B
D
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();
|
|
}
|