dangling.rs:3 return &i; ^~ dangling.rs:1:23: 4:2 note: reference must be valid for the anonymous lifetime #1 defined on the block at 1:22... dangling.rs:1 fn dangling() -> &int { dangling.rs:2 let i = 1234; dangling.rs:3 return &i; dangling.rs:4 } dangling.rs:1:23: 4:2 note: ...but borrowed value is only valid for the block at 1:22 dangling.rs:1 fn dangling() -> &int { dangling.rs:2 let i = 1234; dangling.rs:3 return &i; dangling.rs:4 } error: aborting due to previous error
= ["Tim", "Eston", "Aaron", "Ben"]; let mut odds = nums.iter().map(|&x| x * 2 - 1); for num in odds { do spawn { println!("{:s} says hello from a lightweight thread!", noms[num]); } } }
numbers = [1,2,3];! ! let numbers_arc = Arc::new(numbers);! ! for num in range(0, 3) {! let (port, chan) = Chan::new();! chan.send(numbers_arc.clone());! ! do spawn {! let local_arc = port.recv();! let task_numbers = local_arc.get();! println!("{:d}", task_numbers[num]);! }! }! }