Trying to concurrently borrow a value twice is never going to work. 
You could write a function like "double" for such a situation.

-- 
Abhijeet Gaiha
http://about.me/abhijeet.gaiha


On Sunday, 2 June 2013 at 10:03 AM, Ziad Hatahet wrote:

> I have the following function:
> 
> fn add_equal(x: &mut Complex, y: &Complex) {
>     x.real += y.real;
>     x.imag += y.imag;
> }
> 
> Calling the function with the same variable being passed to both arguments 
> (i.e. add_equal(&mut c, &c)), results in the compile error:
> 
> error: cannot borrow `c` as immutable because it is also borrowed as mutable
> 
> I am guessing this is to avoid aliasing issues? What is the way around this?
> 
> Thanks
> 
> --
> Ziad 
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org (mailto:Rust-dev@mozilla.org)
> https://mail.mozilla.org/listinfo/rust-dev
> 
> 


_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to