You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, here's some suggested content based on my experience teaching the course
I think modules are not very interesting can be pushed to the last day. If we assume the audience can program in some other language, then the rest of the day 2 content (control flow and syntax) can be squeezed to the day 1 afternoon. That means the audience has to wait until the second day to see the famous borrow checker and talk about memory management but that can just be more motivation to show up :)
An exercise that forces people to use pattern matching, result types, option types, and the ? operator (ideally all at once), but only using Copy types. This will let people see these important APIs and learn some pattern matching syntax before running into the borrow checker. Ideally this will force people to read the docs about methods on Options and Results since these types show up everywhere.
you do have to have #[derive(Copy)] and generics like Option<Foo> around but instructors can give a very brief hand-waved explanation for what those are
Designing the HashMap API: There's a lot to say about it wrt generics, trait bounds, and associated types.
Many methods have the bounds, K: Borrow<Q> and Q: Hash + Eq + ?Sized, this is a good example of putting trait bounds on associated types
The entry API is somewhat unique to Rust and is pretty cool that it lets users avoid a lookup
This could be a good intro to generics
maybe talk about ?sized types too
Implementing an Iterator: Here's a contrived example that will let you talk about lifetimes, the index trait, and the impl trait syntax.
/// Given some text, index all the sentences so you can access the Nth sentence in O(1) time.structSentenceIndex<'text>{text:&'text str,sentence_starts:Vec<usize>,}impl<'text> std::ops::Index<usize>forSentenceIndex<'text>{typeOutput:&'text str;// Note that &self has a different lifetime than &'text// The returned sentence str can outlive the SentenceIndex but not the underlying text.fnindex(&self,i:usize) -> &'text str;}impl<'text>SentenceIndex<'text>{fniter(&self) -> implIterator<&'text str>;}
The text was updated successfully, but these errors were encountered:
Hi, here's some suggested content based on my experience teaching the course
I think modules are not very interesting can be pushed to the last day. If we assume the audience can program in some other language, then the rest of the day 2 content (control flow and syntax) can be squeezed to the day 1 afternoon. That means the audience has to wait until the second day to see the famous borrow checker and talk about memory management but that can just be more motivation to show up :)
An exercise that forces people to use pattern matching, result types, option types, and the
?
operator (ideally all at once), but only using Copy types. This will let people see these important APIs and learn some pattern matching syntax before running into the borrow checker. Ideally this will force people to read the docs about methods on Options and Results since these types show up everywhere.#[derive(Copy)]
and generics likeOption<Foo>
around but instructors can give a very brief hand-waved explanation for what those areDesigning the HashMap API: There's a lot to say about it wrt generics, trait bounds, and associated types.
K: Borrow<Q>
andQ: Hash + Eq + ?Sized
, this is a good example of putting trait bounds on associated typesImplementing an Iterator: Here's a contrived example that will let you talk about lifetimes, the index trait, and the impl trait syntax.
The text was updated successfully, but these errors were encountered: