|
|
|
|
|
by steveklabnik
3026 days ago
|
|
Fundamentally, String and &str communicate very different things. String has ownership, &str does not. This is not a reconcilable difference. The closest you could get is automatically allocating &strs into Strings, but then you're introducing silent allocation, which has a host of its own problems. > A constant reference to a string should automatically decompose into a view of that string and that should be that. This is exactly what happens, through Deref coercions. |
|
I absolutely don't think &str should silently allocate for converting to String. But I think &str should zero-allocation convert to &string (and bypass dealloc, too).