harikbon Hacker News • Recommends
On “There’s plenty of room at the Top: computer performance after Moore’s law”
#rustlifetimes#rustgenerics#jongjengset
111K subscribers • 7 videos on Hallway
Intermediate. Assumes working knowledge.
298K views6 years ago3 recommendations
Programming languagesSystems programmingRustMemory managementConcurrency and parallelism
Jon Gjengset live-codes a string splitting utility to explain why and how to use multiple explicit lifetime annotations in Rust.
In the 2019 Rust Survey, a lot of people were asking for video content covering intermediate Rust content. So in this first video (possibly of many), we're going to investigate a case where you need multiple explicit lifetime annotations. We explore why they are needed, and why we need more than one in this particular case. We also talk about some of the differences between the string types and introduce generics over a self-defined trait in the process. And don't worry, I know that what we're implementing exists in the standard library :) Introduction Start a rust project Struct and method definitions for StrSplit and first test How you decide between a library and a binary Start implementing StrSplit When to use match vs if let some Doesn't compile! missing lifetime specifier Can I be wrong by specifying lifetimes? Anonymous lifetime '_ Order lifetimes based on how long they are Anonymous lifetime '_ (with multiple lifetimes) Compile error: lifetime of reference outlives lifetime of borrowed content Static lifetime Bug when a delimiter tails a string What is the ref keyword and why not & What's the * on the left of remainder What is take() doing Mutable references are one level deep Solving a hang with as_mut() Multiple lifetimes, implementing until_char Difference between a str and a String Multiple lifetimes (continued) Generic delimiter (Delimiter trait) char length utf8 Standard library split Q&A You can find the final code at gist.github.com/jonhoo/2a7fdcf79be03e51a5f95cd326f2a1e8. You can watch the live version with comments at youtube.com/watch?v=Oxaex566IrgWhat people say. Engineers point newcomers here for the clearest and most thorough explanation of Rust lifetimes.
harikbon Hacker News • Recommends
On “There’s plenty of room at the Top: computer performance after Moore’s law”
ashish01on Hacker News • Recommends
On “My Favorite Rust Function Signature”
tialaramexon Hacker News • Recommends
On “Next steps for Rust in the kernel”
ly3xqhl8g9on Hacker News • Mentions
On “Why I Use C When I Believe in Memory Safety”