11 ms·
I don't know about "rush" but they should move quickly because Rust is in a fleeting sweet spot of the developer attention cycle where lots of people are eager
by zurn 12y ago
I don't know about "rush" but they should move quickly because Rust is in a fleeting sweet spot of the developer attention cycle where lots of people are eager to jump onboard and it's really good enough for that now.
You are barking up the wrong tree if you are waiting for Go-level simplicity, like the Rust folks have often said.
- Tuna-Fish 12y agoI honestly think that common string handling would be much improved if String could point to either &'static str or an owned buffer, with allocation on modification if necessary, and literals coerced to either &'static str or a String that points to the static buffer depending on type inference. String would never allocate more than it does currently, but it would do it in less predictable situations which some people probably wouldn't like. However, it would basically allow people who don't care that much about short strings to completely eschew all the .as_slice()s and .to_string()s that are currently ubiquitous in any rust string handling.
- lawn 12y agoUsing the experimental slicing syntax x.as_slice() can now be x[] which is a lot better. I'm not sure what will happen to .to_string() but it's a recognized problem.
- FreeFull 12y agoAlternatively, since String implements Deref<str>, you can do &*x, and that works without enabling the slicing syntax (although the syntax is likely to be in 1.0).
- masklinn 12y ago> if String could point to either &'static str or an owned buffer, That used to be the purpose of MaybeOwned, which was just replaced by CowString (a typedef of Cow to String and str). On Cow, a deref returns an immutable slice (with no copy) so slice methods can be called directly on the CowString, `to_mut` copies the source data if necessary and returns a mutable ref, and `into_owned` copies the source data if necessary and returns it. So if you don't really care what you get and whether it's going to be copied or whatever, ask for a CowString and go to town.
- kibwen 12y ago> if String could point to either &'static str or an owned buffer There exists a copy-on-write smart pointer in the standard library that can be used for exactly this purpose: http://doc.rust-lang.org/std/borrow/enum.Cow.html http://doc.rust-lang.org/std/borrow/enum.Cow.html