News for hackers. Stuff that matters.
Re:Rust needs to run, and be easy to use, on every platform by simfoo on Thursday March 08, 2018 @01:56PM (#16546652)
str and String? That naming is horrible. string_view is a much better choice
Re:Rust needs to run, and be easy to use, on every platform by masklinn on Thursday March 08, 2018 @02:22PM (#16546862)
1. string_view makes for much more verbose code when it's the more common version.

2. string_view makes no sense when many str are not actually views into strings but either static data or "cast" bytes.

3. string_view makes no sense when str is the basic builtin type.

Renaming String to something like StrBuf might have made sense, but it's not like it would have been any clearer, people get confused by Path/PathBuf all the same if not more so.

Re:Rust needs to run, and be easy to use, on every platform by tomjakubowski on Thursday March 08, 2018 @03:28PM (#16547362)
It's certainly confusing at first, but the terse naming of "str" is appreciated once you've internalized the difference. "str" is, in most projects I've seen, appears more often in source than "String".
Re:Rust needs to run, and be easy to use, on every platform by weirdwitch on Thursday March 08, 2018 @02:22PM (#16546865)
I completely agree.

Path/PathBuf have better names, but the distinction still isn't immediately obvious.

String/str is the cause of so much confusion.

Re:Rust needs to run, and be easy to use, on every platform by steveklabnik on Thursday March 08, 2018 @02:27PM (#16546902)
I often joke that str/StrBuf is my one wish for a Rust 2.0, but 2.0 will never happen.

This confusion is why we reorganized the book to talk about String and &str very early on, and use them to teach ownership and borrowing.

Re:Rust needs to run, and be easy to use, on every platform by Retra on Thursday March 08, 2018 @09:25PM (#16549410)
It took me like 2 seconds to learn it and haven't been confused since. So... maybe I'm just a grade A genius.