What would Rust look like if it was re-designed today?
What if we could re-design Rust from scratch, with the hindsight that we now have after 10 years. What would be done differently?
This does not include changes that can be potentially implemented in the future, in an edition boundary for example. Such as fixing the Range type to be Copy and implement IntoIterator. There is an RFC for that (https://rust-lang.github.io/rfcs/3550-new-range.html)
Rather, I want to spark a discussion about changes that would be good to have in the language but unfortunately will never be implemented (as they would require Rust 2.0 which is never going to happen).
Some thoughts from me:
Indextrait should return anOptioninstead of panic..unwrap()should be explicit. We don't have this because at the beginning there was no generic associated types.- Many methods in the standard library have incosistent API or bad names. For example,
map_orandmap_or_elsemethods onOption/Resultas infamous examples.format!uses the long name whiledbg!is shortened. Oncharthe methodsis_*takecharby value, but theis_ascii_*take by immutable reference. - Mutex poisoning should not be the default
- Use
funct[T]()for generics instead of turbofishfunct::<T>() #[must_use]should have been opt-out instead of opt-intypekeyword should have a different name.typeis a very useful identifier to have. andtypeitself is a misleading keyword, since it is just an alias.