Tricks of the Trait: Enabling Ergonomic Extractors - Rob Ede
Rust's behavioural abstraction mechanism, the Trait, is a powerful tool for improving the ergonomics of the crates you use every day. In this talk, we'll explore some exciting applications of Traits in library code that cause your application's code to stay clean and concise. I'll start with a beginner's introduction to Traits, comparing and contrasting with similar ideas from other languages to get you up to speed. Then we'll look at a few examples from the standard library and common ways to incorporate trait bounds into generics/type parameters to clean up your code. Finally, we'll dive deeply into the "extractor pattern" used in the modern Rust web frameworks. At first glance, the extractor pattern can look like magic. However, we Rust users often shy away from things that are too magical because we care about retaining control. But this pattern should be easily understandable once we've peeled back the layers and seen how far Traits can be pushed in this way.