tryEvery

Evaluate all parts possibly digesting whole.

If all values of parts implicitly convert to bool true, return the values as an array, otherwise restore whole and return null.

CommonType!T[]
tryEvery
(
S
T...
)
(
ref S whole
,
lazy T parts
)
if (
T.length != 0
)

Examples

1 auto whole = `xyz`;
2 import std.algorithm.searching : skipOver;
3 
4 assert(whole.tryEvery(whole.skipOver('x'),
5                       whole.skipOver('z')) == []); // failing match
6 assert(whole == `xyz`); // should restore whole
7 
8 assert(whole.tryEvery(whole.skipOver('x'),
9                       whole.skipOver('y'),
10                       whole.skipOver('w')) == []); // failing match
11 assert(whole == `xyz`); // should restore whole
12 
13 assert(whole.tryEvery(whole.skipOver('x'),
14                       whole.skipOver('y')) == [true, true]); // successful match
15 assert(whole == `z`); // should digest matching part

Meta