• onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    7 months ago

    Do you mean this for loop?

    for shape in &shapes {
      accum += shape.area();
    }
    

    That does use an iterator

    for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common practice within Rust, which is to loop over anything that implements IntoIterator until the iterator returned by .into_iter() returns None (or the loop body uses break).

    Anti Commercial AI thingy

    CC BY-NC-SA 4.0