Writing Idiomatic Libraries in Rust
summary
Shows how to make concrete API choices: implement conversion traits so functions accept &str, String, slices and arrays via From/Into and FromStr; use builder patterns and derive Default to add fields without breaking semver; implement Iterator and FromIterator for ergonomic, allocation-free construction; encode protocol state so headers cannot be added after the body using session types for HTTP state; enforce quality with clippy and doctests and suggest deriving Debug PartialEq Hash and using serde behind a feature flag.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:13Idiomatic Rust code
- 2:43Goals for libraries
- 4:24Easier to use/contribute
- 9:30Type system for safety
- 13:33Builder patterns in Rust
- 15:24Standard traits for ergonomics
- 18:15APIs like stdlib
- 21:24Session types for state
- 23:52Deep dive: Rust iterators
- 26:00Extending traits for APIs
- 27:28Q&A
related talks
31mFrom C++ APIs to Idiomatic Rust: Wrapper Design Patterns
38mType-level interfaces in Haskell & Rust: pragmatic type-level programming
26mThe Freedom of Static Typing
33mDeclarative programming in Rust
38mMaking Rust Delightful
33mRust and Haskell, sitting in a tree
19mDestructuring Rust strings
44mTyped Design Patterns for the Functional Era
