Skip to content

Latest commit

 

History

History
executable file
·
33 lines (22 loc) · 1.84 KB

File metadata and controls

executable file
·
33 lines (22 loc) · 1.84 KB

rustex-iterators

Rust Exercises for learning to use std::iter::Iterator

Who is this for?

If you already know the basics of Rust and would like to learn more about Rust iterators, these exercises are for you.

If you're just getting started with Rust, you should definitely do the Rustlings exercises (https://github.com/rust-lang/rustlings) first, and then come back and do these ones.

What are these exercises?

Each exercise starts with a function that already succeeds at accomplishing some task. Your goal is to use std::iter::Iterator methods to write a more concise function that exactly matches the original function's behavior.

Why do them?

When you're done, you will have tried roughly half of Iterator's methods (it's a long list!), and you will have a sense of how concise and elegant Rust iterators can be.

How to do these exercises

Start by reading

These exercises are test-driven: an exercise is complete when its tests pass. Run cargo test to see the next error to be fixed, or to confirm your solution.

To advance to the next level, uncomment the next module in lib.rs.

Alternative without local Rust

If you don't have Rust installed locally, you can also manually copy the exercise file contents in the src directory to the Rust Playground and run them there.

Answers

ANSWERS.md contains example answers for each exercise.

Good luck! Run cargo test to start.