about summary refs log tree commit diff
path: root/src/libstd/task.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-26 12:02:16 +0000
committerbors <bors@rust-lang.org>2014-11-26 12:02:16 +0000
commit8fb027e398ef756b7b02a270ef0304be92e70f4d (patch)
treee842ec33ca78ddc8223bdbfc0e6839f7d3643618 /src/libstd/task.rs
parent61af40278909eb899f1bdfbb8c45d4e4fb3dad5d (diff)
parent3293ab14e24d136d0482bb18afef577aebed251e (diff)
downloadrust-8fb027e398ef756b7b02a270ef0304be92e70f4d.tar.gz
rust-8fb027e398ef756b7b02a270ef0304be92e70f4d.zip
auto merge of #19252 : japaric/rust/cow, r=aturon
- Add `IntoCow` trait, and put it in the prelude
- Add `is_owned`/`is_borrowed` methods to `Cow`
- Add `CowString`/`CowVec` type aliases (to `Cow<'_, String, str>`/`Cow<'_, Vec, [T]>` respectively)
- `Cow` implements: `Show`, `Hash`, `[Partial]{Eq,Ord}`
- `impl BorrowFrom<Cow<'a, T, B>> for B`

[breaking-change]s:

- `IntoMaybeOwned` has been removed from the prelude
- libcollections: `SendStr` is now an alias to `CowString<'static>` (it was aliased to `MaybeOwned<'static>`)
- libgraphviz:
  - `LabelText` variants now wrap `CowString` instead of `MaybeOwned`
  - `Nodes` and `Edges` are now type aliases to `CowVec` (they were aliased to `MaybeOwnedVec`)
- libstd/path: `Display::as_maybe_owned` has been renamed to `Display::as_cow` and now returns a `CowString`
- These functions now accept/return `Cow` instead of `MaybeOwned[Vector]`:
  - libregex: `Replacer::reg_replace`
  - libcollections: `str::from_utf8_lossy`
  - libgraphviz: `Id::new`, `Id::name`, `LabelText::pre_escaped_content`
  - libstd: `TaskBuilder::named`

r? @aturon 
Diffstat (limited to 'src/libstd/task.rs')
-rw-r--r--src/libstd/task.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libstd/task.rs b/src/libstd/task.rs
index c852b4efbd8..a0ee08570d9 100644
--- a/src/libstd/task.rs
+++ b/src/libstd/task.rs
@@ -44,16 +44,17 @@
                will likely be renamed from `task` to `thread`."]
 
 use any::Any;
+use borrow::IntoCow;
+use boxed::Box;
 use comm::channel;
 use io::{Writer, stdio};
 use kinds::{Send, marker};
 use option::{None, Some, Option};
-use boxed::Box;
 use result::Result;
 use rustrt::local::Local;
-use rustrt::task;
 use rustrt::task::Task;
-use str::{Str, SendStr, IntoMaybeOwned};
+use rustrt::task;
+use str::{Str, SendStr};
 use string::{String, ToString};
 use sync::Future;
 
@@ -101,8 +102,8 @@ impl TaskBuilder {
     /// Name the task-to-be. Currently the name is used for identification
     /// only in panic messages.
     #[unstable = "IntoMaybeOwned will probably change."]
-    pub fn named<T: IntoMaybeOwned<'static>>(mut self, name: T) -> TaskBuilder {
-        self.name = Some(name.into_maybe_owned());
+    pub fn named<T: IntoCow<'static, String, str>>(mut self, name: T) -> TaskBuilder {
+        self.name = Some(name.into_cow());
         self
     }
 
@@ -264,12 +265,13 @@ pub fn failing() -> bool {
 #[cfg(test)]
 mod test {
     use any::{Any, AnyRefExt};
+    use borrow::IntoCow;
     use boxed::BoxAny;
-    use result;
+    use prelude::*;
     use result::{Ok, Err};
-    use string::String;
+    use result;
     use std::io::{ChanReader, ChanWriter};
-    use prelude::*;
+    use string::String;
     use super::*;
 
     // !!! These tests are dangerous. If something is buggy, they will hang, !!!
@@ -298,7 +300,7 @@ mod test {
 
     #[test]
     fn test_send_named_task() {
-        TaskBuilder::new().named("ada lovelace".into_maybe_owned()).try(proc() {
+        TaskBuilder::new().named("ada lovelace".into_cow()).try(proc() {
             assert!(name().unwrap() == "ada lovelace".to_string());
         }).map_err(|_| ()).unwrap();
     }