Hello, Unfortunately, I accidentally deleted a message from Vadim that I wanted to reply to. However, it had strayed from the topic of the thread anyhow (which was called "sub-grammar for range pattern constants") so I'll just startup a new thread here.
Vadim wrote: > - Does "immutable" mean that the referenced object cannot change > forever, even after current function has returned? It means that the referenced object cannot change for the lifetime of that reference. > Is it possible in Rust to create a hash that stores its' keys by > borrowed reference (assuming that the hash does not outlive > contained keys) and be assured that the keys will not get changed > after having been added to the hash? That would be possible, but the hash would have to be parameterized by the lifetime of the keys. What we typically do instead is to have the hash own the keys. > - Can Rust actually guarantee that &mut are not aliased, - in the > face of all indirection that may happen in a typical program? Yes. That is the job of the borrow checker, and the soundness of the Rust type system depends on it. If you do not make use of managed data (i.e., no `@`), this guarantee is static. Otherwise the guarantee is enforced dynamically. The example program you gave is not supposed to execute without error; the reason that it does is due to bugs. I am about to land (next day or so) a branch fixing a number of such bugs. When I run that program on my branch, I get a compilation failure. This is because, even though you are using `@`, the compiler can clearly see that the dynamic check would fail, and so it flags the error statically. If you modify the program slightly you can evade this static check, but an error should still occur dynamically. Currently it does not (even on my branch), this is issue #5910. Niko _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
