[rust-dev] Two mutable pointers to same memory address?

2014-11-26 Thread grayfox
Hey guys, I'm really new to Rust (actually I've looked on Rust the last 5 hours the first time) but I think I produced something that shouldn't be possible. From the pointer guide I know that the following code will not compile because in the end I would have two mutable pointers to the same

Re: [rust-dev] Two mutable pointers to same memory address?

2014-11-26 Thread Peter Marheine
This is sound- you aren't actually making more than one mutable reference here. Stepping through the operations in your example: 1. i is a mutable pointer to an immutable memory location 2. Pass a pointer to i into `bar`, which can mutate `i`. 3. Deref that pointer so you have a copy of `i`,

Re: [rust-dev] Two mutable pointers to same memory address?

2014-11-26 Thread Daniel Micay
On 26/11/14 12:26 PM, grayfox wrote: Hey guys, I'm really new to Rust (actually I've looked on Rust the last 5 hours the first time) but I think I produced something that shouldn't be possible. From the pointer guide I know that the following code will not compile because in the end I