Practice / rs

Rust practice

Every Rust exercise, built from a topic you can open beside it.

75 exercises runs offline
rs Quiz new What does a lifetime annotation on a returned reference do? How shared and mutable references access values without taking ownership, why borrows conflict, and how to resolve borrow-checker errors. intermediate 1 min · from Borrowing rules rs Predict the output new What does this program print? How shared and mutable references access values without taking ownership, why borrows conflict, and how to resolve borrow-checker errors. beginner 2 min · from Borrowing rules rs Review AI code new Review generated stock transfer How shared and mutable references access values without taking ownership, why borrows conflict, and how to resolve borrow-checker errors. advanced 6 min · from Borrowing rules rs Quiz new Which reference set may safely access the same ordinary value at one point? How shared and mutable references access values without taking ownership, why borrows conflict, and how to resolve borrow-checker errors. beginner 1 min · from Borrowing rules rs Spot the bug new Spot the bug in vector growth How shared and mutable references access values without taking ownership, why borrows conflict, and how to resolve borrow-checker errors. intermediate 4 min · from Borrowing rules rs Quiz new A parent owns child nodes on one thread, while each child needs an optional parent link. … How Rust's Box, Rc, Arc, and Weak model heap ownership, shared ownership, thread-safe sharing, mutation, and non-owning links. intermediate 1 min · from Box, Rc and Arc rs Predict the output new What does this program print? How Rust's Box, Rc, Arc, and Weak model heap ownership, shared ownership, thread-safe sharing, mutation, and non-owning links. beginner 2 min · from Box, Rc and Arc rs Predict the output new Which pair of lines does this program print? How Rust's Box, Rc, Arc, and Weak model heap ownership, shared ownership, thread-safe sharing, mutation, and non-owning links. beginner 2 min · from Box, Rc and Arc rs Review AI code new Review generated listener hub How Rust's Box, Rc, Arc, and Weak model heap ownership, shared ownership, thread-safe sharing, mutation, and non-owning links. advanced 6 min · from Box, Rc and Arc rs Spot the bug new Spot the bug in the Rc tree How Rust's Box, Rc, Arc, and Weak model heap ownership, shared ownership, thread-safe sharing, mutation, and non-owning links. intermediate 4 min · from Box, Rc and Arc rs Quiz new A function chooses at runtime between two capturing closure expressions and returns the c… Learn how Rust closures capture their environment, acquire Fn traits, and express ownership in generics, return values, threads, and dynamic dispatch. intermediate 1 min · from Closures rs Quiz new Which statement about move || println!("{label}") is correct when label is a String? Learn how Rust closures capture their environment, acquire Fn traits, and express ownership in generics, return values, threads, and dynamic dispatch. intermediate 1 min · from Closures rs Predict the output new What does this program print? Learn how Rust closures capture their environment, acquire Fn traits, and express ownership in generics, return values, threads, and dynamic dispatch. beginner 2 min · from Closures rs Review AI code new Review generated audit handler Learn how Rust closures capture their environment, acquire Fn traits, and express ownership in generics, return values, threads, and dynamic dispatch. advanced 6 min · from Closures rs Spot the bug new Spot the bug in the Fn bound Learn how Rust closures capture their environment, acquire Fn traits, and express ownership in generics, return values, threads, and dynamic dispatch. intermediate 4 min · from Closures rs Quiz new Which standard collection most directly expresses a key-value map that must iterate by ke… Choose Rust's standard collections by ordering, uniqueness, lookup, and range semantics, then handle ownership, Entry, and iteration correctly. beginner 1 min · from Collections rs Quiz new Which expression calls build_profile only when user_id is absent? Choose Rust's standard collections by ordering, uniqueness, lookup, and range semantics, then handle ownership, Entry, and iteration correctly. intermediate 1 min · from Collections rs Predict the output new What does this program print? Choose Rust's standard collections by ordering, uniqueness, lookup, and range semantics, then handle ownership, Entry, and iteration correctly. beginner 2 min · from Collections rs Review AI code new Review generated product summary Choose Rust's standard collections by ordering, uniqueness, lookup, and range semantics, then handle ownership, Entry, and iteration correctly. advanced 6 min · from Collections rs Spot the bug new Spot the bug in the HashMap report Choose Rust's standard collections by ordering, uniqueness, lookup, and range semantics, then handle ownership, Entry, and iteration correctly. intermediate 4 min · from Collections rs Quiz new What happens when code constructs values.iter().map(transform) but never uses the returne… Understand Rust iterator ownership, lazy adapters, short-circuiting, error propagation, and the contract of a custom Iterator. beginner 1 min · from Iterators rs Predict the output new What does this program print? Understand Rust iterator ownership, lazy adapters, short-circuiting, error propagation, and the contract of a custom Iterator. beginner 2 min · from Iterators rs Quiz new Which expression returns the first integer parse error instead of silently dropping inval… Understand Rust iterator ownership, lazy adapters, short-circuiting, error propagation, and the contract of a custom Iterator. intermediate 1 min · from Iterators rs Review AI code new Review generated weight conversion Understand Rust iterator ownership, lazy adapters, short-circuiting, error propagation, and the contract of a custom Iterator. advanced 6 min · from Iterators rs Spot the bug new Spot the bug in the lazy map Understand Rust iterator ownership, lazy adapters, short-circuiting, error propagation, and the contract of a custom Iterator. intermediate 4 min · from Iterators rs Predict the output new What does this program print? Express relationships among references precisely with lifetime parameters, elision, borrowed structs, 'static, and higher-ranked bounds. intermediate 2 min · from Lifetime elision and annotations rs Review AI code new Review generated borrowed key view Express relationships among references precisely with lifetime parameters, elision, borrowed structs, 'static, and higher-ranked bounds. advanced 6 min · from Lifetime elision and annotations rs Quiz new What does one lifetime name shared by two parameters and a return value guarantee? Express relationships among references precisely with lifetime parameters, elision, borrowed structs, 'static, and higher-ranked bounds. intermediate 1 min · from Lifetime elision and annotations rs Spot the bug new Spot the bug in the local reference Express relationships among references precisely with lifetime parameters, elision, borrowed structs, 'static, and higher-ranked bounds. beginner 4 min · from Lifetime elision and annotations rs Quiz new Which statement correctly distinguishes String: static from a static reference? Express relationships among references precisely with lifetime parameters, elision, borrowed structs, 'static, and higher-ranked bounds. intermediate 1 min · from Lifetime elision and annotations rs Quiz new What does fn choose<'a>(x: &'a str, y: &'a str) -> &'a str mean? Lifetimes describe where references remain valid; understand inference, annotations, elision, 'static, and higher-ranked bounds to design precise borrowed APIs. intermediate 1 min · from Lifetimes rs Quiz new When is a for-lifetime higher-ranked bound appropriate? Lifetimes describe where references remain valid; understand inference, annotations, elision, 'static, and higher-ranked bounds to design precise borrowed APIs. advanced 1 min · from Lifetimes rs Predict the output new What does this program print? Lifetimes describe where references remain valid; understand inference, annotations, elision, 'static, and higher-ranked bounds to design precise borrowed APIs. beginner 2 min · from Lifetimes rs Review AI code new Review generated record view Lifetimes describe where references remain valid; understand inference, annotations, elision, 'static, and higher-ranked bounds to design precise borrowed APIs. advanced 6 min · from Lifetimes rs Spot the bug new Spot the bug in the local reference Lifetimes describe where references remain valid; understand inference, annotations, elision, 'static, and higher-ranked bounds to design precise borrowed APIs. beginner 4 min · from Lifetimes rs Quiz new A package named store-domain has src/lib.rs and src/main.rs. From main.rs, how should the… Distinguish Cargo packages, crates, and modules, then use paths, visibility, and re-exports to design a stable Rust API. intermediate 1 min · from Modules and crates rs Quiz new Which statement correctly distinguishes a Cargo package, a crate, and a module? Distinguish Cargo packages, crates, and modules, then use paths, visibility, and re-exports to design a stable Rust API. beginner 1 min · from Modules and crates rs Predict the output new What does this program print? Distinguish Cargo packages, crates, and modules, then use paths, visibility, and re-exports to design a stable Rust API. beginner 2 min · from Modules and crates rs Review AI code new Review generated catalog API Distinguish Cargo packages, crates, and modules, then use paths, visibility, and re-exports to design a stable Rust API. advanced 6 min · from Modules and crates rs Spot the bug new Spot the bug in the module path Distinguish Cargo packages, crates, and modules, then use paths, visibility, and re-exports to design a stable Rust API. intermediate 4 min · from Modules and crates rs Quiz new A function only reads a Shipment during the call and never stores it. Which parameter bes… Rust uses ownership, moves, copies, and deterministic destruction to govern resources; learn when values transfer, borrow, and drop. beginner 1 min · from Ownership rs Predict the output new Which pair of lengths does this program print? Rust uses ownership, moves, copies, and deterministic destruction to govern resources; learn when values transfer, borrow, and drop. beginner 2 min · from Ownership rs Predict the output new What does this program print? Rust uses ownership, moves, copies, and deterministic destruction to govern resources; learn when values transfer, borrow, and drop. beginner 2 min · from Ownership rs Review AI code new Review generated job removal Rust uses ownership, moves, copies, and deterministic destruction to govern resources; learn when values transfer, borrow, and drop. advanced 6 min · from Ownership rs Spot the bug new Spot the bug in the moved label Rust uses ownership, moves, copies, and deterministic destruction to govern resources; learn when values transfer, borrow, and drop. beginner 4 min · from Ownership rs Quiz new Which statement about Copy and Clone is correct? Track moves, copies, borrows, partial moves, and drops so each Rust value has one clear owner at every program point. beginner 1 min · from Moves, partial moves and drops rs Predict the output new In which order are these lines printed? Track moves, copies, borrows, partial moves, and drops so each Rust value has one clear owner at every program point. beginner 2 min · from Moves, partial moves and drops rs Predict the output new What does this program print? Track moves, copies, borrows, partial moves, and drops so each Rust value has one clear owner at every program point. intermediate 2 min · from Moves, partial moves and drops rs Review AI code new Review a generated dispatch helper Track moves, copies, borrows, partial moves, and drops so each Rust value has one clear owner at every program point. advanced 7 min · from Moves, partial moves and drops rs Spot the bug new Spot the bug in the moved label Track moves, copies, borrows, partial moves, and drops so each Rust value has one clear owner at every program point. beginner 4 min · from Moves, partial moves and drops rs Quiz new In match &job { Job { owner, .. } => ... }, where owner is a String field, what is the us… Use exhaustive matches, destructuring, guards, and binding patterns while avoiding hidden wildcard cases and accidental moves. intermediate 1 min · from Pattern matching rs Quiz new Which slice pattern accepts exactly a command name followed by one argument? Use exhaustive matches, destructuring, guards, and binding patterns while avoiding hidden wildcard cases and accidental moves. beginner 1 min · from Pattern matching rs Predict the output new What does this program print? Use exhaustive matches, destructuring, guards, and binding patterns while avoiding hidden wildcard cases and accidental moves. beginner 2 min · from Pattern matching rs Review AI code new Review an event classifier Use exhaustive matches, destructuring, guards, and binding patterns while avoiding hidden wildcard cases and accidental moves. advanced 6 min · from Pattern matching rs Spot the bug new Spot the bug in the match pattern Use exhaustive matches, destructuring, guards, and binding patterns while avoiding hidden wildcard cases and accidental moves. intermediate 4 min · from Pattern matching rs Quiz new Why does Future::poll receive self as Pin<&mut Self>? Pin establishes a no-move contract for address-sensitive values; Unpin determines when that restriction can be safely removed. intermediate 1 min · from Pin and Unpin rs Quiz new What happens when a Pin<Box<T>> binding is moved to another variable? Pin establishes a no-move contract for address-sensitive values; Unpin determines when that restriction can be safely removed. intermediate 1 min · from Pin and Unpin rs Predict the output new Which three lines does this program print, in order? Pin establishes a no-move contract for address-sensitive values; Unpin determines when that restriction can be safely removed. intermediate 2 min · from Pin and Unpin rs Review AI code new Review a generated pinned job Pin establishes a no-move contract for address-sensitive values; Unpin determines when that restriction can be safely removed. advanced 8 min · from Pin and Unpin rs Spot the bug new Spot the bug in the Ticket self-reference Pin establishes a no-move contract for address-sensitive values; Unpin determines when that restriction can be safely removed. advanced 4 min · from Pin and Unpin rs Quiz new Which statement about Cell<String> is correct? Use Cell value replacement and RefCell runtime borrowing to model interior mutability without hiding borrow conflicts or thread boundaries. intermediate 1 min · from Cell and RefCell rs Predict the output new What does this program print? Use Cell value replacement and RefCell runtime borrowing to model interior mutability without hiding borrow conflicts or thread boundaries. beginner 2 min · from Cell and RefCell rs Predict the output new Does this program compile, and what does it print? Use Cell value replacement and RefCell runtime borrowing to model interior mutability without hiding borrow conflicts or thread boundaries. intermediate 2 min · from Cell and RefCell rs Review AI code new Review a generated event bus Use Cell value replacement and RefCell runtime borrowing to model interior mutability without hiding borrow conflicts or thread boundaries. advanced 8 min · from Cell and RefCell rs Spot the bug new Spot the bug in the callback registry Use Cell value replacement and RefCell runtime borrowing to model interior mutability without hiding borrow conflicts or thread boundaries. advanced 4 min · from Cell and RefCell rs Quiz new A function accepts &str and receives &Box<String> through deref coercion. What happens to… Rust smart pointers combine indirection with ownership, sharing, and destruction; understand the real boundaries of Deref, Drop, and wrappers. intermediate 1 min · from Smart pointers rs Predict the output new What does this program print? Rust smart pointers combine indirection with ownership, sharing, and destruction; understand the real boundaries of Deref, Drop, and wrappers. beginner 2 min · from Smart pointers rs Predict the output new Which pair of values does this program print? Rust smart pointers combine indirection with ownership, sharing, and destruction; understand the real boundaries of Deref, Drop, and wrappers. beginner 2 min · from Smart pointers rs Review AI code new Review a generated secret wrapper Rust smart pointers combine indirection with ownership, sharing, and destruction; understand the real boundaries of Deref, Drop, and wrappers. advanced 8 min · from Smart pointers rs Spot the bug new Spot the bug in the Rc node graph Rust smart pointers combine indirection with ownership, sharing, and destruction; understand the real boundaries of Deref, Drop, and wrappers. intermediate 4 min · from Smart pointers rs Quiz new A function only searches text during the call and stores nothing. Which ordinary paramete… Understand String and str ownership, UTF-8 byte boundaries, Unicode text units, and when a string API should borrow or allocate. beginner 1 min · from Strings rs Quiz new Which statement about Rust string units is correct? Understand String and str ownership, UTF-8 byte boundaries, Unicode text units, and when a string API should borrow or allocate. intermediate 1 min · from Strings rs Predict the output new What does this program print? Understand String and str ownership, UTF-8 byte boundaries, Unicode text units, and when a string API should borrow or allocate. beginner 2 min · from Strings rs Review AI code new Review generated name summary Understand String and str ownership, UTF-8 byte boundaries, Unicode text units, and when a string API should borrow or allocate. advanced 6 min · from Strings rs Spot the bug new Spot the bug in the UTF-8 prefix Understand String and str ownership, UTF-8 byte boundaries, Unicode text units, and when a string API should borrow or allocate. intermediate 4 min · from Strings