News for hackers. Stuff that matters.
Re:Rust 1.17 by vvanders on Thursday April 27, 2017 @01:43PM (#14213357)
It's because you don't have a String to begin with, just two const memory values(which most of the time are baked into the program binary in C/C++, not sure about Rust).
Re:Rust 1.17 by danieldk on Thursday April 27, 2017 @01:52PM (#14213415)
which most of the time are baked into the program binary in C/C++, not sure about Rust

Pretty much the same, string literals are of type &'static str, which is a string slice with a static lifetime. Since literals are not `mut`, you cannot mutate them.

Re:Rust 1.17 by vvanders on Thursday April 27, 2017 @01:55PM (#14213448)
Yeah, semantically you're right. I'm talking about actual binary representation. Some systems/runtimes copy them to the heap/etc while others let you reference the actual memory in the loaded binary.

Back when I did more embedded stuff we cared since it could increase your runtime memory by a non-trival amount depending on what the platform did.

Re:Rust 1.17 by steveklabnik on Thursday April 27, 2017 @02:01PM (#14213493)
In Rust's case, to be clear, they're stored in .rodata. That's where the &'static str points to.

The auto copy to the heap behavior is controversial, desired by many for ergonomic reasons, disliked by others for implicit heap allocation. We'll see if it gets added in the future or not!

Re:Rust 1.17 by vvanders on Thursday April 27, 2017 @02:06PM (#14213536)
Yeah, you'd find me in the latter camp for sure :).

Thanks for the details, it's appreciated.