Hi there!
The Rust core language is extended pretty quickly (in comparison to many other languages) and we regularly get new type-system features or new syntax. Some, if not many, of those changes affect API design: with a specific feature, one can build a better API than without that feature.
The standard library’s API is not different in this regard: pretty much the whole API was designed for the Rust 1.0 core language and new core language features could improve the API in several places. To give a few specific examples:
Possible API improvements
- with generic associated types, one could improve the
Deref
trait to make it more generic and powerful:trait Deref { type Target<'a>; fn deref(&self) -> Self::Target; }
- with the
impl Trait
feature, one could hide a lot of implementation detail (maybe returnimpl Iterator
instead ofMap
inIterator::map()
) - with GATs (again), one could write collection traits which would potentially influence the API of all collections
(However, I think everyone agrees that possible improvement exist; concrete examples are not important for my question)
Of course, all those examples are backwards incompatible. That’s a problem, we don’t like to break users code; we promised stability. So we can’t simply use those improvements.
As probably everyone here is aware, there is the “Evolving Rust through Epochs” RFC. It specifies how we can change most of the Rust core language in a backwards incompatible way while avoiding breakage as well as a community split. It mentions the standard library at two points:
- “Epochs are designated by the year in which they occur, and represent a release in which several elements come together: […] The standard library and other core ecosystem crates have been updated to use the new features as appropriate.”
- “More generally, breaking changes to the standard library are not possible.”
These statements seem to contradict each other. I wonder if/how it is possible to introduce breaking changes to the standard library. I think that breaking changes are required, because IMO regularly updating the std’s API to use the core language as idiomatic as possible is a good thing. I just never heard anything about these kinds of std
changes from the Rust community.
In Summary
- I think we should update
std
(from time to time!) in a backwards incompatible way to use new language features in order to improvestd
s API. - In my naive worldview,
std
is simply a library crate and we could bump the major version while the old version is still available (just like epochs). - The epochs RFC even manages to introduce breaking changes to the core language, so I feel like it should be certainly possible to introduce breaking changes to
std
.
Are there plans on how to introduce breaking changes to std
? Or is it impossible to do? Why?
Sorry if this has been discussed before, I haven’t found any previous threads. I asked a similar question on StackOverflow (without answer).