TryBugHunt

Rust iterator exercises

Rust iterators are zero-cost abstractions, but they are lazy: calling .map() without .collect() or a consuming loop executes nothing. Furthermore, indexing a Rust String with byte offsets panics if it splits a multi-byte UTF-8 character.

Solve practical Rust iterator and string processing bugs.

See the 11 exercisesOr follow the 30-day path

The iterators bugs you will meet

The exercises

Errors you might be searching for

More JavaScript practice by topic

Questions

Why can't I index a Rust String like s[0]?

Rust Strings are strictly UTF-8 encoded byte arrays. Indexing by character would be O(N) rather than O(1), and byte indexing could bisect a unicode character.