Skip to content

Borrowing practice problems in Rust

Difficulty:
Category:
Tag:

Showing 33 of 33

Status Title Difficulty
Borrowing through Option Medium
Borrow it or own it: your first lifetime decision Easy
Closures hold their borrows Medium
Designing signatures: T, &T, &mut T, impl Into<T> Medium
E0499: cannot borrow as mutable more than once Medium
E0502: cannot borrow as mutable because also borrowed as immutable Easy
Fn, FnMut, FnOnce: the closure hierarchy Medium
How to read a borrow-check diagnostic Easy
Indexing in a loop is usually a borrow-checker workaround — and clippy knows Medium
Interior mutability: moving the check from compile time to run time Medium
Iterator invalidation, and the bug class that stopped existing Medium
iter, iter_mut, into_iter: all three, one Vec Easy
iter_mut(): mutating every element without ever holding two &mut Medium
`longest`: writing your first `'a` Medium
Move or borrow: the two ways to pass a value Easy
&mut: exclusive access, and why `mut` appears twice Easy
Needless clone: the most common review comment in Rust Medium
NLL Problem Case #3, the entry API, and the limits of today's checker Hard
Non-lexical lifetimes: a borrow ends at its last use Easy
Reborrowing: why &mut sometimes moves and sometimes doesn't Hard
ref, ref mut, and default binding modes in edition 2024 Medium
Scoped threads: borrow, do not clone Easy
Set algebra with BTreeSet Easy
Slices are borrows Easy
split_at_mut and the disjointness-proof APIs Medium
Split borrows: the checker reasons about places, not variables Medium
&str not &String, &[T] not &Vec<T> — deref coercion and ptr_arg Easy
The FnMut borrow gauntlet: a log you can read afterwards Medium
The owner is frozen too: E0503, E0505, E0506 Medium
Two inputs, one output lifetime Medium
Two-phase borrows: why v.push(v.len()) compiles Hard
What a &mut parameter actually promises Medium
Zero-copy parsing: borrow, don't allocate Medium