4 ms·
Here's one case. Instead of let letters = word.chars().filter(|ch| ch.is_alphabetic()); you can just write let letters = word.chars().filter(is_alphabeti
by dmit 3y ago
Here's one case. Instead of
let letters = word.chars().filter(|ch| ch.is_alphabetic());
you can just write
let letters = word.chars().filter(is_alphabetic);
since the difference between "methods" and "functions" is purely syntactic.
- usrusr 3y agoMost languages that have a way to define dot-syntax functions that aren't actually methods of the type also come with the ability to use any zero-arg method (both true methods and dot-syntax extension functions) as a one-arg function reference, or rather n-arg methods as n+1-arg function references. No need to crowd the unqualified namespace just to be able to use them without wrapping in a lambda.