Skip to content

Collections exercise - #315

Merged
jonathanpallant merged 2 commits into
mainfrom
collections-exercise
Oct 14, 2026
Merged

jonathanpallant merged 2 commits into
mainfrom
collections-exercise

Conversation

@robamu

@robamu robamu commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

First draft of a collections exercise, fixes #16 .

The exercise itself is currently relatively short and only includes Vec, BTreeSet and HashMap. Maybe we should also add VecDeque? I included some quiz questions.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Deploying ferrous-systems-rust-exercises with  Cloudflare Pages  Cloudflare Pages

Latest commit: 805b4cc
Status: ✅  Deploy successful!
Preview URL: https://a1455c77.ferrous-systems-rust-exercises.pages.dev
Branch Preview URL: https://collections-exercise.ferrous-systems-rust-exercises.pages.dev

View logs

@robamu
robamu force-pushed the collections-exercise branch 2 times, most recently from 269048e to 049950e Compare September 21, 2026 12:45
@robamu
robamu marked this pull request as ready for review September 21, 2026 13:12
@robamu
robamu force-pushed the collections-exercise branch from 049950e to be8b6ba Compare September 21, 2026 13:13
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated
Comment thread exercise-book/src/fundamentals/collections.md Outdated

@jonathanpallant jonathanpallant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just some minor nits.

In general, I think the example Type we put inline in the next should be in the same format the audience needs to write it in their own program. That is String is OK because that type is in the prelude, but std::collections::HashMap needs qualifying because it is not.

I proposed some text changes but I don't recommend just accepting them in the Github UI because the paragraphs will probably need re-wrapping. Also you could probably slightly reformat them to make them better - Github was only letting me apply suggestions to one line at a time.

**A**:

Only if you use a [scoped thread](https://doc.rust-lang.org/std/thread/fn.scope.html) which
allows to borrow non-`'static` data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
allows to borrow non-`'static` data.
allows you to borrow non-`'static` data.

@robamu
robamu requested a review from jonathanpallant October 2, 2026 15:37
@jonathanpallant

Copy link
Copy Markdown
Member

On reflection, I think Q2 and Q3 are too advanced for this exercise. We would use this on day 2 of an Open Intro, and we don't cover threads and send/sync until the very end.

Discussing String and &str is OK - you could talk about modifying the original String after it has been placed in the collection (you get different outcomes depending on whether you moved it, cloned it, or borrowed it).

@robamu

robamu commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Okay. Maybe they can be moved into another exercise though (possibly in adapted form?).

Discussing String and &str is OK - you could talk about modifying the original String after it has been placed in the collection (you get different outcomes depending on whether you moved it, cloned it, or borrowed it).

this could be an additional step for the exercise as well.

@jonathanpallant

Copy link
Copy Markdown
Member

Maybe they can be moved into another exercise though (possibly in adapted form?).

If there's an exercise where they make sense, then sure! But that's another PR.

@robamu
robamu force-pushed the collections-exercise branch from 3f9ba72 to 805b4cc Compare October 14, 2026 11:09
@jonathanpallant
jonathanpallant added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit b74612d Oct 14, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collections exercise

2 participants