Re:Rust needs to run, and be easy to use, on every platform
by masklinn on Thursday March 08, 2018 @02:38PM
(#16546994)
> Why is one capitalized and one lowercase?
Because one is a pretty bog-standard struct: https://doc.rust-lang.org/src/alloc/string.rs.html#294-296 while the other is a primitive type: https://doc.rust-lang.org/std/#primitives
Lowercase (i8, u64) or anonymity (`[]`, &, *) means you're dealing with something fundamental to the language. Not just with special compiler/language support (like Result) but way below that, something the language doesn't itself express but has intrinsic knowledge of.
Re:Rust needs to run, and be easy to use, on every platform
by steveklabnik on Thursday March 08, 2018 @02:26PM
(#16546891)
The lowercase one is a language primitive, and so is lowercased like all language primitives.
The uppercase one is a standard library type, and so is uppercased like all library types.
Re:Rust needs to run, and be easy to use, on every platform
by juliangoldsmith on Thursday March 08, 2018 @02:27PM
(#16546904)
std::String is a struct, and str is a type defined by the language.
There's a summary of the differences at [0].
[0]: http://www.ameyalokare.com/rust/2017/10/12/rust-str-vs-Strin...
I kind of agree with the sibling that the naming is odd. Why not call them String and Slice or String and MutableString? Using different ‘spellings” of the same word seems like it only encourage some confusion.