Re:Tour of Rust
by Misdicorl on Monday July 13, 2020 @09:52AM
(#23820737)
What issues arise by aliasing &str and &String to the same (&str) implementation? Does any code actually rely on &String pointing at the String itself rather than the bytes of the string?
Perhaps its more strange/broken to special case &String that it is to have the (imo) warty &str.
Re:Tour of Rust
by dbaupp on Monday July 13, 2020 @08:09PM
(#23827149)
Unsafe generic code likely cares, where it is coercing a &T to a *const T and then relying on pointer stability/consistency. It will also cause difficulties with methods like ‘.capacity()’, because that info is lost with &str.
Perhaps its more strange/broken to special case &String that it is to have the (imo) warty &str.