|
|
|
|
|
by seabee
4129 days ago
|
|
Aliasing is only a problem because they prevent you assuming two values are independent of each other: a write to one could affect the other, if they are aliased. When you enforce immutability of aliases, as Rust does, aliasing stops being a special case. The underlying value may be the same, but the behaviour is identical to when they are independent. The only time you have problems thereafter is when you do weird things with the value's address which only coincidentally works. For example, comparing interned strings or Java's Integer objects using == works for other interned strings and small integers, respectively. |
|