Skip to content

Borrowing practice problems in Rust

Difficulty:
Category & tags Filters active
Category:
Tag:

Showing 33 of 33

Title Difficulty
Accessing an owned value while it is borrowed Medium
Borrowing through Option Medium
Borrow it or own it: your first lifetime decision Easy
Carry a running maximum through mutable iteration Medium
Choose parameter types and shrink an enum Medium
Closures hold their borrows Medium
Count words with the HashMap entry API Hard
E0499: cannot borrow as mutable more than once Medium
E0502: cannot borrow as mutable because also borrowed as immutable Easy
Filter records without cloning their tags Medium
Fn, FnMut, FnOnce: the closure hierarchy Medium
How to read a borrow-check diagnostic Easy
iter, iter_mut, into_iter: all three, one Vec Easy
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
Non-lexical lifetimes: a borrow ends at its last use Easy
Read a log after its closure finishes Medium
Reborrowing: why &mut sometimes moves and sometimes doesn't Hard
ref, ref mut, and default binding modes in edition 2024 Medium
Remove matching values without invalidating iteration Medium
Scoped threads: borrow, do not clone Easy
Set algebra with BTreeSet Easy
Share a log with RefCell and report borrow conflicts Medium
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
Subtract the minimum with a mutable iterator 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