Skip to content

Lifetimes practice problems in Rust

Difficulty:
Category:
Tag:

Showing 19 of 19

Status Title Difficulty
Borrow it or own it: your first lifetime decision Easy
Cow: borrow until you have to own Medium
Cow in API design: impl Into<Cow<str>> Hard
flat_map: expand a range spec like "1-3,7,10-12" Medium
Generics, traits and lifetimes in one signature Medium
Let elision do it Easy
`longest`: writing your first `'a` Medium
Make the lint happy: `'_` in return paths Easy
Make your own collection iterable, all three ways Hard
move: when the closure must own its captures Medium
Needless clone: the most common review comment in Rust Medium
Non-lexical lifetimes: a borrow ends at its last use Easy
Returning impl Trait, and what edition 2024 changed Hard
Slices are borrows Easy
Trait objects and lifetimes: Box<dyn Trait + 'a> Hard
`T: 'static` in practice — a type-erased handler registry Hard
Two inputs, one output lifetime Medium
Zero-copy parsing: borrow, don't allocate Medium
Zero-copy tokenizer: `Parser<'a>` Hard