Skip to content

Traits practice problems in Rust

Difficulty:
Category:
Tag:

Showing 42 of 42

Status Title Difficulty
AsRef, Borrow, and signatures your callers can actually use Medium
Associated type or generic parameter? Hard
Blanket impls, and why you can never carve out an exception Hard
Box<dyn Trait>: trait objects, DSTs and dynamic dispatch Medium
BTreeMap range queries Medium
Capstone: a fully-typed fallible parser Hard
Cow in API design: impl Into<Cow<str>> Hard
Custom hashing: beating SipHash on integer keys Hard
Deref and the coercion you have been using all along Medium
Deref polymorphism, and the day your method disappears Medium
#[derive(Debug)] and the three shapes of debug output Easy
Deriving traits, and when derive gets the bounds wrong Easy
Display, Debug, and the ToString blanket impl Easy
Dyn compatibility: the actual rules Hard
Enum dispatch: the third option Medium
Extension traits: adding methods to types you do not own Medium
Fn, FnMut, FnOnce: the closure hierarchy Medium
From impls: the machinery behind `?` Medium
From, Into, and your first blanket impl with teeth Medium
From, Into, TryFrom: conversions that cannot lie Medium
Generics, traits and lifetimes in one signature Medium
Hash and the Hash/Eq contract Medium
HashMap fundamentals: get, get_mut and the Hash/Eq contract Easy
Implementing std::error::Error Medium
Implement Iterator by hand: the Collatz sequence Medium
IntoIterator: one bound that accepts five containers Medium
Make your own collection iterable, all three ways Hard
Operator overloading: + is just a trait method Medium
PartialEq and Eq: why floats can be compared but not Eq Medium
PartialOrd and Ord: derived ordering follows declaration order Medium
Sealed traits: public to use, closed to implement Medium
SemVer for Rust APIs: what actually breaks Hard
size_hint and DoubleEndedIterator: an iterator with two ends Hard
String building: push_str, write!, and the 590x cliff Easy
Supertraits and default methods Medium
The `Future` trait: `Output`, `Poll`, and your first hand-written future Easy
The orphan rule and the newtype escape Hard
Traits as shared behaviour Easy
TryFrom, TryInto, and the type that cannot exist Medium
Tuple structs and unit structs: the other two shapes Easy
use declarations: nested groups, as, self, and _ Medium
Write your own adapters, with an extension trait Hard