diff --git a/std/algorithm/searching.d b/std/algorithm/searching.d index 8254c8b1871..da1f603d9ca 100644 --- a/std/algorithm/searching.d +++ b/std/algorithm/searching.d @@ -2588,6 +2588,10 @@ template canFind(alias pred="a == b") assert(!canFind(arr, 4)); // find one of several needles + assert([0, 1, 2, 3].canFind(3, 2)); + assert([0, 1, 2, 3].canFind(3, 2) == 2); // second needle found + assert([0, 1, 2, 3].canFind([1, 3], 2) == 2); + assert(canFind(arr, [1, 2], [2, 3])); assert(canFind(arr, [1, 2], [2, 3]) == 1); assert(canFind(arr, [1, 7], [2, 3])); @@ -2596,13 +2600,6 @@ template canFind(alias pred="a == b") assert(canFind(arr, [1, 3], [2, 4]) == 0); } -// More multiple needles -@safe unittest -{ - assert([1, 2, 3].canFind(3, 2) == 2); - assert([1, 2, 3].canFind([1, 3], 2) == 2); -} - /** * Example using a custom predicate. * Note that the needle appears as the second argument of the predicate.