diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/task.rs | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/libstd/task.rs')
| -rw-r--r-- | src/libstd/task.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libstd/task.rs b/src/libstd/task.rs index e9b01063f94..7c5e984ad36 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -41,6 +41,7 @@ use comm::{Sender, Receiver, channel}; use io::Writer; use kinds::{Send, marker}; use option::{None, Some, Option}; +use owned::Box; use result::{Result, Ok, Err}; use rt::local::Local; use rt::task::Task; @@ -56,7 +57,7 @@ use str::{Str, SendStr, IntoMaybeOwned}; /// /// If you wish for this result's delivery to block until all /// children tasks complete, recommend using a result future. -pub type TaskResult = Result<(), ~Any:Send>; +pub type TaskResult = Result<(), Box<Any:Send>>; /// Task configuration options pub struct TaskOpts { @@ -67,9 +68,9 @@ pub struct TaskOpts { /// The size of the stack for the spawned task pub stack_size: Option<uint>, /// Task-local stdout - pub stdout: Option<~Writer:Send>, + pub stdout: Option<Box<Writer:Send>>, /// Task-local stderr - pub stderr: Option<~Writer:Send>, + pub stderr: Option<Box<Writer:Send>>, } /** @@ -173,7 +174,7 @@ impl TaskBuilder { Some(gen) => gen(f), None => f }; - let t: ~Task = Local::take(); + let t: Box<Task> = Local::take(); t.spawn_sibling(self.opts, f); } @@ -190,7 +191,8 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - pub fn try<T:Send>(mut self, f: proc():Send -> T) -> Result<T, ~Any:Send> { + pub fn try<T:Send>(mut self, f: proc():Send -> T) + -> Result<T, Box<Any:Send>> { let (tx, rx) = channel(); let result = self.future_result(); @@ -240,7 +242,7 @@ pub fn spawn(f: proc():Send) { /// the function or an error if the task failed /// /// This is equivalent to TaskBuilder::new().try -pub fn try<T:Send>(f: proc():Send -> T) -> Result<T, ~Any:Send> { +pub fn try<T:Send>(f: proc():Send -> T) -> Result<T, Box<Any:Send>> { TaskBuilder::new().try(f) } @@ -264,7 +266,7 @@ pub fn deschedule() { use rt::local::Local; // FIXME(#7544): Optimize this, since we know we won't block. - let task: ~Task = Local::take(); + let task: Box<Task> = Local::take(); task.yield_now(); } @@ -507,10 +509,10 @@ fn test_try_fail_message_owned_str() { #[test] fn test_try_fail_message_any() { match try(proc() { - fail!(box 413u16 as ~Any:Send); + fail!(box 413u16 as Box<Any:Send>); }) { Err(e) => { - type T = ~Any:Send; + type T = Box<Any:Send>; assert!(e.is::<T>()); let any = e.move::<T>().unwrap(); assert!(any.is::<u16>()); |
