Created
December 13, 2012 20:18
-
-
Save bstrie/4279444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct A { | |
v :~[int], | |
} | |
impl A { | |
fn foo(&mut self) { | |
//error: illegal borrow unless pure: unique value in aliasable, mutable location | |
let pa = &mut self.v[1]; | |
//note: impure due to assigning to dereference of mutable & pointer | |
*pa = 5; | |
} | |
} | |
fn main() { | |
let mut a = A{v:~[1,2,3]}; | |
{ //that compiles fine | |
let pb = &mut a.v[1]; | |
*pb = 6; | |
} | |
a.foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment