2 ms·
You can do: let foo = "1234".to_string(); let mut foo = foo; foo = "5678"; This only works if you have ownership of the variable though. And in pr
by nicoburns 5y ago
You can do:
let foo = "1234".to_string();
let mut foo = foo;
foo = "5678";
This only works if you have ownership of the variable though. And in practice it's a pretty good compromise, because it's pretty hard to do this by mistake.
Note: const in rust is different to const in some other languages: it represents a value that is duplicated inline into each use site at compile time.
- makapuf 5y agoYes I think i see it more like constexpr.