2012-08-17 19:30:29 -05:00
|
|
|
//buggy.rs
|
|
|
|
use std;
|
2012-09-05 14:32:05 -05:00
|
|
|
use std::map::hashmap;
|
|
|
|
use std::map;
|
2012-08-17 19:30:29 -05:00
|
|
|
|
|
|
|
fn main() {
|
2012-08-30 14:54:50 -05:00
|
|
|
let buggy_map :hashmap<uint, &uint> =
|
|
|
|
hashmap::<uint, &uint>(|x| { uint::hash(*x) },
|
|
|
|
|x, y| { uint::eq(*x, *y) });
|
2012-08-17 19:30:29 -05:00
|
|
|
buggy_map.insert(42, ~1); //~ ERROR illegal borrow
|
|
|
|
|
|
|
|
// but it is ok if we use a temporary
|
|
|
|
let tmp = ~2;
|
|
|
|
buggy_map.insert(43, tmp);
|
|
|
|
}
|