diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-03-16 15:49:12 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-03-26 22:44:40 -0400 |
| commit | 34c5a09ce3c18874de7150afbf689ce0f94c7c20 (patch) | |
| tree | 18f0b794a9fff5b530003e5d37bd2f1124b31b7d /src/libcore/task | |
| parent | 5011d05db25fd3dfc0a9dc41fd914633ffb85469 (diff) | |
| download | rust-34c5a09ce3c18874de7150afbf689ce0f94c7c20.tar.gz rust-34c5a09ce3c18874de7150afbf689ce0f94c7c20.zip | |
option: rm functions that duplicate methods
Diffstat (limited to 'src/libcore/task')
| -rw-r--r-- | src/libcore/task/local_data_priv.rs | 3 | ||||
| -rw-r--r-- | src/libcore/task/mod.rs | 7 | ||||
| -rw-r--r-- | src/libcore/task/spawn.rs | 15 |
3 files changed, 11 insertions, 14 deletions
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 59f4942b3a4..a4fd18ec094 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -13,7 +13,6 @@ use cast; use cmp::Eq; use libc; -use option; use prelude::*; use task::rt; use task::local_data::LocalDataKey; @@ -181,6 +180,6 @@ pub unsafe fn local_modify<T:Durable>( // Could be more efficient by doing the lookup work, but this is easy. let newdata = modify_fn(local_pop(task, key)); if newdata.is_some() { - local_set(task, key, option::unwrap(newdata)); + local_set(task, key, newdata.unwrap()); } } diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 349a10bb809..3e980daaa08 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -35,7 +35,6 @@ use cell::Cell; use cmp::Eq; -use option; use result::Result; use comm::{stream, Chan, GenericChan, GenericPort, Port, SharedChan}; use prelude::*; @@ -410,7 +409,7 @@ pub impl TaskBuilder { do fr_task_builder.spawn || { ch.send(f()); } - match option::unwrap(result).recv() { + match result.unwrap().recv() { Success => result::Ok(po.recv()), Failure => result::Err(()) } @@ -839,14 +838,14 @@ fn test_add_wrapper() { fn test_future_result() { let mut result = None; do task().future_result(|+r| { result = Some(r); }).spawn { } - fail_unless!(option::unwrap(result).recv() == Success); + fail_unless!(result.unwrap().recv() == Success); result = None; do task().future_result(|+r| { result = Some(r); }).unlinked().spawn { fail!(); } - fail_unless!(option::unwrap(result).recv() == Failure); + fail_unless!(result.unwrap().recv() == Failure); } #[test] #[should_fail] #[ignore(cfg(windows))] diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index b97a682c4e5..f353db5ae70 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -75,7 +75,6 @@ use cast; use cell::Cell; use container::Map; -use option; use comm::{Chan, GenericChan, GenericPort, Port, stream}; use prelude::*; use unstable; @@ -194,7 +193,7 @@ fn each_ancestor(list: &mut AncestorList, if coalesce_this.is_some() { // Needed coalesce. Our next ancestor becomes our old // ancestor's next ancestor. ("next = old_next->next;") - *list = option::unwrap(coalesce_this); + *list = coalesce_this.unwrap(); } else { // No coalesce; restore from tmp. ("next = old_next;") *list = tmp_list; @@ -290,7 +289,7 @@ fn each_ancestor(list: &mut AncestorList, fn with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>, blk: &fn(TaskGroupInner) -> U) -> U { // If this trips, more likely the problem is 'blk' failed inside. - let tmp_arc = option::swap_unwrap(&mut *parent_group); + let tmp_arc = parent_group.swap_unwrap(); let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) }; *parent_group = Some(tmp_arc); result @@ -374,7 +373,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: *rust_task, let newstate = util::replace(&mut *state, None); // If 'None', the group was failing. Can't enlist. if newstate.is_some() { - let group = option::unwrap(newstate); + let group = newstate.unwrap(); taskset_insert(if is_member { &mut group.members } else { &mut group.descendants }, me); *state = Some(group); @@ -390,7 +389,7 @@ fn leave_taskgroup(state: TaskGroupInner, me: *rust_task, let newstate = util::replace(&mut *state, None); // If 'None', already failing and we've already gotten a kill signal. if newstate.is_some() { - let group = option::unwrap(newstate); + let group = newstate.unwrap(); taskset_remove(if is_member { &mut group.members } else { &mut group.descendants }, me); *state = Some(group); @@ -414,7 +413,7 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { // That's ok; only one task needs to do the dirty work. (Might also // see 'None' if Somebody already failed and we got a kill signal.) if newstate.is_some() { - let group = option::unwrap(newstate); + let group = newstate.unwrap(); for taskset_each(&group.members) |sibling| { // Skip self - killing ourself won't do much good. if sibling != me { @@ -519,7 +518,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // None { ancestor_list(None) } let tmp = util::replace(&mut **ancestors, None); if tmp.is_some() { - let ancestor_arc = option::unwrap(tmp); + let ancestor_arc = tmp.unwrap(); let result = ancestor_arc.clone(); **ancestors = Some(ancestor_arc); AncestorList(Some(result)) @@ -549,7 +548,7 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) { let mut notify_chan = if opts.notify_chan.is_none() { None } else { - Some(option::swap_unwrap(&mut opts.notify_chan)) + Some(opts.notify_chan.swap_unwrap()) }; let child_wrapper = make_child_wrapper(new_task, child_tg, |
