diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-10-18 10:38:46 +0200 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-10-18 10:43:41 +0200 |
| commit | 3011801256d112e1930726058362b8fd22ea40dd (patch) | |
| tree | a2b7c4fe80d64bf520a76cba762cab423e2a26b4 /src/libstd/unstable/sync.rs | |
| parent | d4a32386f3b61a4997de54ed00c0a80fd07ecc75 (diff) | |
Made `std::task::TaskBuilder::future_result()` easier to use
Diffstat (limited to 'src/libstd/unstable/sync.rs')
| -rw-r--r-- | src/libstd/unstable/sync.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index f3945d8f3c9..459df572b78 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -580,32 +580,29 @@ mod tests { // Now try the same thing, but with the child task blocking. let x = Exclusive::new(~~"hello"); let x2 = Cell::new(x.clone()); - let mut res = None; let mut builder = task::task(); - builder.future_result(|r| res = Some(r)); + let res = builder.future_result(); do builder.spawn { let x2 = x2.take(); assert!(x2.unwrap() == ~~"hello"); } // Have to get rid of our reference before blocking. util::ignore(x); - res.unwrap().recv(); + res.recv(); } #[test] #[should_fail] fn exclusive_new_unwrap_conflict() { let x = Exclusive::new(~~"hello"); let x2 = Cell::new(x.clone()); - let mut res = None; let mut builder = task::task(); - builder.future_result(|r| res = Some(r)); + let res = builder.future_result(); do builder.spawn { let x2 = x2.take(); assert!(x2.unwrap() == ~~"hello"); } assert!(x.unwrap() == ~~"hello"); - // See #4689 for why this can't be just "res.recv()". - assert!(res.unwrap().recv() == task::Success); + assert!(res.recv() == task::Success); } #[test] |
