Skip to content

Instantly share code, notes, and snippets.

@zslayton
Created December 8, 2013 07:38
Show Gist options
  • Save zslayton/7854355 to your computer and use it in GitHub Desktop.
Save zslayton/7854355 to your computer and use it in GitHub Desktop.
extern mod extra;
use extra::treemap::TreeMap;
fn main(){
let mut map : ~TreeMap<~str, ~str> = ~TreeMap::new();
map.swap(~"dog", ~"cat");
let value : &~str = map.find(&~"dog").unwrap();
println!("dog -> {:s}", *value);
map.pop(&~"dog");
println!("dog -> {:s}", *value);
}
/*
strmap.rs:11:1: 11:4 error: cannot borrow `*map` as mutable because it is also borrowed as immutable
strmap.rs:11 map.pop(&~"dog");
^~~
strmap.rs:9:21: 9:24 note: second borrow of `*map` occurs here
strmap.rs:9 let value : &~str = map.find(&~"dog").unwrap();
^~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/zslayton/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /home/zslayton/rust/src/librustc/lib.rs:393
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment