macro_rules! is_contained_in {
([$($matcher:expr),* $(,)?]) => { ... };
($($matcher:expr),* $(,)?) => { ... };
}
Expand description
Matches a JSON array where every element matches one of the provided matchers.
This macro succeeds if:
- the input is a JSON array
- every element in the array matches exactly one matcher
- matchers are not reused
- extra matchers may be provided and left unmatched
- order does not matter
This macro fails if:
- the input is not a JSON array
- any element in the array fails to match all matchers
Accepts both bracketed (json::is_contained_in!([ ... ])
) and unbracketed (json::is_contained_in!(...)
) forms.
Example:
let value = j!(["a", "b", "c"]);
assert_that!(
value,
json::is_contained_in![eq("a"), eq("b"), eq("c"), eq("d")]
);
§How it works
- Each matcher can match at most one element
- Extra matchers may remain unused
- Every element in the array must be matched
§Alias
This macro is re-exported as json::is_contained_in!
.