Skip to content

Ownership practice problems in Rust

Difficulty:
Category & tags Filters active
Category:
Tag:

Showing 41 of 41

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
Capstone: an ownership-only job scheduler Hard
Choose parameter types and shrink an enum Medium
Conditional moves and drop flags Hard
Copy values: translate points and find their centroid Easy
C strings and ownership across FFI Medium
Enum state machines with data-carrying transitions Hard
Extend a vector with insertion and consuming iteration Hard
Field init shorthand and struct update syntax Easy
Giving ownership back Medium
Group anagrams with a map Medium
iter, iter_mut, into_iter: all three, one Vec Easy
Joining owned strings Easy
Let a channel receiver finish by dropping its senders Medium
Method receivers and the consuming builder Medium
Move or borrow: the two ways to pass a value Easy
Move semantics: the relay Easy
Move values through a pipeline without cloning Easy
move: when the closure must own its captures Medium
Moving out of &mut: take, replace, swap Medium
mpsc channels: message passing basics Easy
Mutating an Option in place Medium
&mut: exclusive access, and why mut appears twice Easy
Observe scope cleanup and control vector drop order Medium
Observe when destructors are skipped Hard
Ownership inside loops Medium
Ownership through function calls Easy
Partial moves: taking one field and leaving the rest Medium
peekable and next_if: write a tokeniser Hard
ptr::read, write, copy, copy_nonoverlapping, drop_in_place Medium
Reading E0382 line by line Easy
Schedule destruction with a by-value helper Easy
Shadowing is not moving Easy
Stack, heap, and what a variable actually holds Easy
String vs &str, part 2: functions that take and return text Medium
Structs: naming your data Easy
Take a payload while keeping its destructor valid Hard
The stack, the heap, and Box<T> Easy
The three rules of ownership Easy