OxL Reference

method iter.enumerate

Pairs (index, element) with the index counting from 0.

Example:

oxl✓ checked in CI
fn main() io {
  for (i, name) in ["a", "b"].iter().enumerate() {
    print("{i}: {name}")
  }
}
Output
0: a
1: b
pub(api) move fn enumerate() -> iter<(usize, T)>

Complexity. O(1) per element.

Since. 1.0.0-beta

Returns

iter<(usize, T)>

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/iter.oxl:298

See also