4 ms·
Thanks for this is was very helpful. Honestly I think the main thing that trips people up here is the naming convention. If it was String and StringView rather
by pixel_fcker 11y ago
Thanks for this is was very helpful.
Honestly I think the main thing that trips people up here is the naming convention. If it was String and StringView rather than str I don't think people would have nearly as much trouble. I guess the name was chosen for brevity considering how pervasive &str is in rust code.
- steveklabnik 11y agoYeah, it's sort of historic. I like to joke that renaming String to StrBuf is my only wish for Rust 2.0. That said, if anything, it would be StrBuf and str, because str is a primitive type, hence the lower case. It almost wasn't a primitive type, but there were drawbacks, so we kept it as one.
- bjz_ 11y agoWhat were the drawbacks?
- steveklabnik 11y agohttps://github.com/rust-lang/rust/pull/19612 https://github.com/rust-lang/rust/pull/19612
- Manishearth 11y agoI believe that StrBuf or something similar was the name for a short time after the ~str removal.
- bjz_ 11y agoI would be against giving the more expensive type the shorter name. That said, I kind of agree with Steve that having a `Buf` suffix would help.