RustConf 2023 - The standard library is special. Let's change that.

The standard library's unique characteristics, including nightly features and prelude, can be customized for optimization and error handling.

Key takeaways
  • The standard library is special in many ways, such as using nightly features, bypassing coherence, and having a prelude.
  • To make the standard library less special, fat preludes can be created and made available to all crates, but this requires a stability attribute.
  • The stability attribute can indicate whether an item is stable or not, and can be used to guarantee the size and layout of types.
  • The standard library has an implementation of Error that permits any error type to be converted into box_din_error.
  • The add trait is a language item because the compiler needs to know about it for optimization.
  • There are 232 lang items that are required for optimization, but are difficult to implement and require cooperation with the compiler.
  • Specialization is a difficult feature to implement and requires expertise in type theory.
  • Negative implications are useful for trait and language items, but can be eliminated by annotating the module.
  • Standard library has an impl for converting box_din_error to Result.
  • Specialization could solve the problem of unspecified behavior in the standard library.
  • Fat preludes would provide significant benefit, but there are edge cases to consider, such as when an unstable item is used.
  • Stable and unstable attributes handle whether an item is stable or not.
  • Default impl for all lengths is desirable, but would require expertise in type theory.
  • A prelude is something provided at the crate root and allows for implicit imports.