Q:

How does Iterator::all work?

I do not understand iter().all. This code from the docs works:
let d = [2, 3, 4, 6, 8];
assert!(a.iter().all(|x| *x > 0));

Why does the one below not work?
for x in d.iter().all(|x| *x > 2) {
   println!("{} is bigger than 2", x);
}

A:

all tests that the given predicate holds true for all elements. It returns false as soon as it finds an element that does not match the predicate, or true if all elements match. It is not used to iterate over matching elements. You should probably use filter for that. See the Iterator::all documentation.

