Chain Filter and Map
Start with vec![1, 2, 3, 4, 5, 6]. Filter to keep only numbers greater than 3, then use map to square each one. Collect and print the result.
Expected output:
text
[16, 25, 36]
Hints:
- Chain:
.iter().filter(|x| **x > 3).map(|x| x * x).collect() - Filter gives
&&i32, so use**xto compare the value - Map receives
&i32, sox * xworks
rust
fn main() {
}