Skip to content

Rust

Reference iterators in Rust

One thing you've likely noticed when writing Rust is how its ownership system makes heap allocations fairly explicit. One way to avoid these when iterating is to yield references to heap-allocated objects, rather than copies. While simple in theory, this concept can get complex rather quickly in practice.