Array iter's type

A array of Option type, How to get the index of iter

If I understand your question:

fn main() {
    let array = [Some(1), None, None, None];
    for (idx, x) in array.into_iter().enumerate() {
        println!("{idx}: {x:?}");
1 Like

Thanks! Great!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.