From 9eeeb2a9f340f3bc7724c8006169a8099f030e9c Mon Sep 17 00:00:00 2001 From: Ralf Biedert Date: Sun, 21 Jan 2024 10:42:24 +0100 Subject: [PATCH] Clarify some iterator wording. --- content/_index.md | 14 +++++++++----- static/index.js | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/content/_index.md b/content/_index.md index 8c4d8c4..b9f5456 100644 --- a/content/_index.md +++ b/content/_index.md @@ -5588,7 +5588,7 @@ Many users would expect your collection to _just work_ in `for` loops. You need {{ tablesep() }} -> As you can see, the **IntoIterator** {{ std(page="std/iter/trait.IntoIterator.html") }} trait is what actually connects your collection with the **IntoIter** struct you created in the previous tab. +> As you can see, the **IntoIterator** {{ std(page="std/iter/trait.IntoIterator.html") }} trait is what actually connects your collection with the **IntoIter** struct you created in the previous tab. The two siblings of **IntoIter** (**Iter** and **IterMut**) are discussed in the next tab. @@ -5606,8 +5606,8 @@ Many users would expect your collection to _just work_ in `for` loops. You need In addition, if you want your collection to be useful when borrowed you should implement: -* **`struct Iter {}`** — Create struct holding `&Collection` for shared iteration. -* **`struct IterMut {}`** — Similar, but holding `&mut Collection` for mutable iteration. +* **`struct Iter {}`** — Create struct holding `&Collection` state for shared iteration. +* **`struct IterMut {}`** — Similar, but holding `&mut Collection` state for mutable iteration. * **`impl Iterator for Iter {}`** — Implement shared iteration. * **`impl Iterator for IterMut {}`** — Implement mutable iteration. @@ -5635,6 +5635,10 @@ Also you might want to add convenience methods: +{{ tablesep() }} + +> The code for borrowing interator support is basically just a repetition of the previous steps with a slightly different types, e.g., `&T` vs `T`. + @@ -5655,7 +5659,7 @@ To allow **3rd party iterators** to 'collect into' your collection im * **`impl FromIterator for Collection {}`** — Now `some_iter.collect::>()` works. * **`impl Extend for Collection {}`** — Now `c.extend(other)` works. -In addition, also consider adding the extra traits from **`std::iter`** {{ std(page="std/iter/index.html#") }} to your iterators: +In addition, also consider adding the extra traits from **`std::iter`** {{ std(page="std/iter/index.html#") }} to your previous structs: @@ -5697,7 +5701,7 @@ In addition, also consider adding the extra traits from **`std::iter`** {{ std(p {{ tablesep() }} > Writing collections can be work. The good news is, if you followed all -> steps in this section your collection will feel like a _first class citizen_. +> these steps your collections will feel like _first class citizens_. diff --git a/static/index.js b/static/index.js index 3a98276..808b6a4 100644 --- a/static/index.js +++ b/static/index.js @@ -67,7 +67,9 @@ const subtitles = [ "Aquaaaariiiiiiiuuuuuuuuuuus", "Rust is fast, somewhere between a snake and a mongoose.", "\"In the jungle, the mighty jungle, the lion sleeps tonight\" ... Chorus: \"Async-await, async-await ...\"", - "The 3.6 roentgen cheat sheet.", + "The 3.6 roentgen of Rust cheat sheets.", + "This page was intentionally not left blank.", + "It's like standing on the shoulders of hobbits.", ];