[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

[rust-dev] Overflow when benchmarking

2014-11-26 Thread Ben Wilson
Hey folks, I've started writing some rust code lately and run into weird behavior when benchmarking. When running https://gist.github.com/benwilson512/56f84d4625f11feb #[bench] fn test_overflow(b: mut Bencher) { let nums = [0i, ..100]; b.iter(|| { let mut x = 0i; for i in

Re: [rust-dev] Overflow when benchmarking

2014-11-26 Thread Steven Fackler
The `nums` array is allocated on the stack and is 8 MB (assuming you're on a 64 bit platform). On Wed Nov 26 2014 at 8:23:08 PM Ben Wilson benwilson...@gmail.com wrote: Hey folks, I've started writing some rust code lately and run into weird behavior when benchmarking. When running

Re: [rust-dev] Overflow when benchmarking

2014-11-26 Thread Ben Wilson
Doh, of course. Thanks, it's been a while since I've written low level stuff. On Wed, Nov 26, 2014 at 10:28 PM, Steven Fackler sfack...@gmail.com wrote: The `nums` array is allocated on the stack and is 8 MB (assuming you're on a 64 bit platform). On Wed Nov 26 2014 at 8:23:08 PM Ben Wilson