
Specialization in Rust and Why It Is Still Unstable
Specialization would let a blanket impl have faster special cases. After years of work it is still nightly only, held back by soundness problems with lifetimes.
Everything you need to level up your coding skills.

Specialization would let a blanket impl have faster special cases. After years of work it is still nightly only, held back by soundness problems with lifetimes.

When you know every implementor of a trait, an enum can stand in for a trait object with no allocation and with inlinable calls. The cost is a closed set.

Rust needs no DI container. Define a trait for the dependency, take it in the constructor and wire the real types in main. Tests pass a fake instead.

In languages without sum types, the visitor pattern exists to add operations to a type hierarchy. Rust's enums and match usually make it unnecessary, with a few exceptions.

Rust forbids adding inherent methods to foreign types, but a trait you define can. Extension traits are how itertools, futures and tokio add methods to the standard library.

std::any::Any lets you ask a trait object what concrete type it holds. Learn downcast_ref, Box<dyn Any>, the as_any pattern for your own traits, and when an enum is the better design.

E0369 means an operator like + or == was used on a type that does not implement the matching trait. Fix it with a derive, a trait bound on the generic, or an explicit impl.

A tuple struct with one field costs nothing at runtime and stops you passing a user id where an order id belongs. Learn construction, derives, Deref pitfalls and the orphan rule workaround.

Build a custom derive from scratch with syn, quote and proc-macro2: parse the struct, generate an impl, report errors with spans and test the expansion.

macro_rules! matches token patterns and expands them into code. Learn fragment types, repetition and when a macro beats a function.

Wrap IDs in tiny types so a UserId cannot be passed where an OrderId is expected. Derive sqlx::Type and Serde with transparent, and keep the cost at zero.

Send means a value can move to another thread and Sync means a reference to it can be shared. See which types lack them and why the compiler decides for you.
We send one email when a new post is published. No spam.