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

auto whole = `xyz`;
import std.algorithm.searching : skipOver;

assert(whole.tryEvery(whole.skipOver('x'),
					  whole.skipOver('z')) == []); // failing match
assert(whole == `xyz`); // should restore whole

assert(whole.tryEvery(whole.skipOver('x'),
					  whole.skipOver('y'),
					  whole.skipOver('w')) == []); // failing match
assert(whole == `xyz`); // should restore whole

assert(whole.tryEvery(whole.skipOver('x'),
					  whole.skipOver('y')) == [true, true]); // successful match
assert(whole == `z`); // should digest matching part

Meta