2 ms·
Author here: I agree that they make sense! I think the nuance is between "makes sense" and "fits into the mental model Rust otherwise encourages," i.e. thinkin
by woodruffw 7y ago
Author here: I agree that they make sense!
I think the nuance is between "makes sense" and "fits into the mental model Rust otherwise encourages," i.e. thinking about `T` and `&T` as the fundamental building blocks for ownership semantics. In that context, being unable to directly instantiate a `str` (or having `&String` be a thing that you can occasionally produce when you mean `&str) is deeply confusing to newcomers.
- jkoudys 7y agoI'd even made your same comment about Strings over on reddit last week - it's not like the ways it's doing it are wrong at all. It's more that newbies can suffer decision paralysis when you are obsessed with learning the "right way" to do something, but there's no clear answer. Do I `.map(String::from)`, do I `.map(From::from)` and let things infer? Do I `.map(|s| s.into())`? `.map(|s| s.to_owned())`? `.map(|s| s.to_string())`? You can drive yourself crazy over the most meaningless, pointless questions in your code. The surprising thing is, I find rust an incredibly effective language at sparing me from worrying about trivialities. Once you learn the slight differences in what all those things mean, you can be pretty direct. Overall I find rust one of the harder languages to write, but one of the easiest to read, and reading code is generally where you'll spend more time.