1 point
*
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
9 points
I think they meant using for accumulating, like this:
shapes.iter().map(Shape::area).sum()
4 points
2 points
Oh, I see. That would be interesting to benchmark too 👍
Anti Commercial AI thingy
Anti Commercial AI thingy
Off-topic, but does that actually work? I would assume OpenAI would just ignore it and you’d have to prove that they did so.