The iter() method can be used on any data structure that can be turned into a slice, such as arrays and vectors.
Another way to iterate over a collection of items is using a functional style. The above code would look like
```rust
fn main() {
    let array = [1, 2];

    array.iter().for_each(|element| println!("{}", element));
}
```
This uses the for_each method on iterators to call the println! macro on each element of the array.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence