all is an iterator method that returns true only when every item satisfies a condition. Pass it a closure that receives each item and returns true or false. section 9.1.3
When an iterator yields references, match the closure pattern to those references. For example, iter().all(|&x| x.is_alphabetic()) checks the characters themselves rather than their references. section 9.1.3
Checking every character
let smaller_vec = ('A'..'z').collect::<Vec<char>>(); println!("All alphabetic? {}", smaller_vec.iter().all(|&x| x.is_alphabetic())); println!("All less than 행? {}", smaller_vec.iter().all(|&x| x < '행')); This prints false for the alphabetic check because the range includes nonalphabetic characters, and true for the comparison with 행. section 9.1.3
The method accepts a closure through a generic type. Its signature uses &mut self and requires F: FnMut(Self::Item) -> bool, meaning the closure receives an iterator item and returns a Boolean. section 12.1
Use all alongside other iterator checks:
- Use any when one matching item is enough; it can stop as soon as it finds a match. section 9.1.3
- Use find when you need the matching item, or position when you need its index. section 9.3



