Created
October 3, 2012 19:56
-
-
Save eevee/3829449 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extern mod std; | |
use std::map::HashMap; | |
use std::map::Set; | |
use std::map::vec_from_set; | |
enum Choice { | |
Many(Set<int>), | |
One(int), | |
} | |
fn main(++_argv: ~[~str]) { | |
let mut choices: ~[Choice] = ~[Many(HashMap())]; | |
for vec::each_mut(choices) |choice| { | |
match *choice { | |
Many(opts) => { | |
if opts.size() == 1 { | |
*choice = One(vec_from_set(opts)[0]); | |
} | |
} | |
One(_) => {} | |
} | |
} | |
log(error, choices); | |
} |
This file contains hidden or 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
borrowenum.rs:17:17: 17:22 error: illegal borrow unless pure: enum variant in aliasable, mutable location | |
borrowenum.rs:17 Many(opts) => { | |
^~~~~ | |
borrowenum.rs:19:20: 19:27 note: impure due to assigning to dereference of mutable & pointer | |
borrowenum.rs:19 *choice = One(vec_from_set(opts)[0]); | |
^~~~~~~ | |
error: aborting due to previous error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment