If you want to get the semantics of other languages, just clone the left-hand side with ".clone()".
If you want to get the semantics of other languages, just clone the left-hand side with ".clone()".
Isn't that true for every language?
No offense intended, but this strongly reminds me of the "Sufficiently Smart Compiler" [1]
The Java community had more than enough time to implement that, especially compared to a young language like Rust, so there's probably a reason they don't have it yet.
javac compiles chained string concatenation to a sequence of StringBuilder calls, and HotSpot knows how to specifically optimize those:
https://groups.google.com/forum/m/#!topic/jvm-languages/KtVB...
That said, I'm sure there are common cases it doesn't catch.
Closest real world example to a sufficiently smart compiler is GHC, and that can be plenty dumb at times.
Here, SQL can also be viewed as a lazy evaulated programming language, due to its declarative nature and the fact that the execution order is not defined in the code, but instead an (hopefully optimal) execution order is determined by the query planner.
Which, string handling being specifically optimised by the compiler, is exactly what was being discussed upthread?