|
7 | 7 | <p>In this homework, you will implement functionality similar to that of the <a href="https://doc.rust-lang.org/std/primitive.str.html#method.split"><code>split</code></a> method on |
8 | 8 | <a href="https://doc.rust-lang.org/std/primitive.str.html"><code>str</code></a> in the Rust standard library. You will need to construct a <code>Split</code> struct that implements |
9 | 9 | the <a href="https://doc.rust-lang.org/1.85.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> trait, where the items it yields are slices of the original string (the |
10 | | -<code>haystack</code>), deliminated by some <code>delimiter</code>.</p> |
| 10 | +<code>haystack</code>), delimited by some <code>delimiter</code>.</p> |
11 | 11 | <p>A correct solution is likely going to contain very few lines of code (~20). However, the interaction |
12 | 12 | between the lifetimes and your code will probably be tricky to implement on your own.</p> |
13 | 13 | <p>Instead of trying to figure this out on your own, we ask that you watch the following livestream |
|
17 | 17 | <h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2> |
18 | 18 | <p>Please don’t spend too much time on this! The goal here is to understand how lifetimes work, not how |
19 | 19 | to specifically implement something that is already in the standard library.</p> |
20 | | -<p><strong>Also, the starter code we have given you is slightly different to how Jon implements this |
21 | | -iterator, so be aware of the difference. It is not so different that you will need to rewrite |
22 | | -everything from scratch.</strong> You will, however, need to make some changes to the starter code in order |
23 | | -to get things to compile (mainly removing the placeholder <code>'static</code> lifetimes).</p> |
| 20 | +<p><strong>Also, the starter code we have given you is slightly different to how Jon implements <code>Split</code>, so |
| 21 | +be aware of the difference. It is not so different that you will need to rewrite everything from |
| 22 | +scratch.</strong> You will, however, need to make some changes to the starter code in order to get things |
| 23 | +to compile (mainly removing the placeholder <code>'static</code> lifetimes).</p> |
24 | 24 | <p><em>Note that Jon does not reveal how to make those compile until the end of the livestream (the |
25 | | -“Multiple lifetimes” sections).</em></p> |
| 25 | +“Multiple lifetimes” sections). After that section, you only need to keep watching if you want to |
| 26 | +complete the extra credit in <code>src/split_pattern.rs</code>.</em></p> |
26 | 27 | <p><strong>Finally, it is probably in your interest to watch the livestream <em>before</em> writing any code, as you |
27 | 28 | will not need to write more than 20 lines of code, and understanding the concepts is far more |
28 | 29 | important.</strong> If you try to finesse how much of the livestream you watch and how much code you write |
29 | 30 | in between the sections, you will likely end up spending <strong>more</strong> time than if you just watched the |
30 | 31 | entire livestream and wrote your own solution.</p> |
31 | | -<br> |
32 | 32 | <h3 id="livestream"><a class="doc-anchor" href="#livestream">§</a>Livestream</h3> |
33 | 33 | <p>The livestream is 90 minutes, but you can skip several sections. We’ve listed the sections you |
34 | 34 | <em>should</em> watch below (you can jump around via the chapters on YouTube). Of course, we would |
|
0 commit comments