d-webservice-example/source/d_webservice_example/util/algorithm.d

14 lines
380 B
D
Raw Normal View History

2019-06-05 01:38:26 +02:00
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();
}