How to apply a function to each element of a vector in Rust (analog of map)?
Hello colleagues! I just started learning Rust, switched from Python, and I have a problem with processing vectors.
In Python I used to do this:
```python
numbers = [1, 2, 3, 4]
squared = list(map(lambda x: x**2, numbers)) # [1, 4, 9, 16]
```
Or using list comprehension, which is even more convenient.
In Rust I wrote something like this:
```rust
fn main() {
let numbers = vec![1, 2, 3, 4];
// I want to get a new vector with squares of numbers
let squared: Vec = numbers.map(|x| x * x).collect();
println!("{:?}", squared);
}
```
The compiler gives an error:
```
error[E0599]: no method named `map` found for struct `Vec` in the current scope
```
I understand that Rust is not Python, and everything is stricter with types here. But how do I process each element of a vector?