3 ms·
It actually needs the & in both my example and your second example, because .filter receives a reference to the item being iterated. Your second example doesn't
by bilkow 4y ago
It actually needs the & in both my example and your second example, because .filter receives a reference to the item being iterated. Your second example doesn't compile: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=43e16b2aba4b07f8a450a71831feb339 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- saghm 4y agoAh, you're right! I had forgotten filter worked like that. I'll have to concede that equality with references to `Copy` is somewhat annoying when dealing with closures (and closures in general are one of the few parts of Rust I do consistently wish had better ergonomics, although I understand why it's hard).