about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2014-11-21 17:10:42 -0500
committerJorge Aparicio <japaricious@gmail.com>2014-11-25 11:22:23 -0500
commit3293ab14e24d136d0482bb18afef577aebed251e (patch)
treec21d2568d6eaf1cc1835034cf2557277c4e8d58b /src/libstd
parent48ca6d1840818e4a8977d00ed62cf0e8e0e5d193 (diff)
downloadrust-3293ab14e24d136d0482bb18afef577aebed251e.tar.gz
rust-3293ab14e24d136d0482bb18afef577aebed251e.zip
Deprecate MaybeOwned[Vector] in favor of Cow
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path/mod.rs6
-rw-r--r--src/libstd/path/posix.rs4
-rw-r--r--src/libstd/path/windows.rs4
-rw-r--r--src/libstd/prelude.rs3
-rw-r--r--src/libstd/rt/mod.rs4
-rw-r--r--src/libstd/task.rs20
6 files changed, 22 insertions, 19 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index a185a29a700..ce3440ead40 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -74,7 +74,7 @@ use fmt;
 use iter::Iterator;
 use option::{Option, None, Some};
 use str;
-use str::{MaybeOwned, Str, StrPrelude};
+use str::{CowString, MaybeOwned, Str, StrPrelude};
 use string::String;
 use slice::{AsSlice, CloneSliceAllocPrelude};
 use slice::{PartialEqSlicePrelude, SlicePrelude};
@@ -830,7 +830,7 @@ pub struct Display<'a, P:'a> {
 
 impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.as_maybe_owned().as_slice().fmt(f)
+        self.as_cow().fmt(f)
     }
 }
 
@@ -840,7 +840,7 @@ impl<'a, P: GenericPath> Display<'a, P> {
     /// If the path is not UTF-8, invalid sequences will be replaced with the
     /// Unicode replacement char. This involves allocation.
     #[inline]
-    pub fn as_maybe_owned(&self) -> MaybeOwned<'a> {
+    pub fn as_cow(&self) -> CowString<'a> {
         String::from_utf8_lossy(if self.filename {
             match self.path.filename() {
                 None => {
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 2b444fdc32b..bdce759a1df 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -551,14 +551,14 @@ mod tests {
             ($path:expr, $exp:expr) => (
                 {
                     let path = Path::new($path);
-                    let mo = path.display().as_maybe_owned();
+                    let mo = path.display().as_cow();
                     assert!(mo.as_slice() == $exp);
                 }
             );
             ($path:expr, $exp:expr, filename) => (
                 {
                     let path = Path::new($path);
-                    let mo = path.filename_display().as_maybe_owned();
+                    let mo = path.filename_display().as_cow();
                     assert!(mo.as_slice() == $exp);
                 }
             )
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 9f81de72980..fc367710131 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -1326,10 +1326,10 @@ mod tests {
         assert_eq!(path.filename_display().to_string(), "".to_string());
 
         let path = Path::new("foo");
-        let mo = path.display().as_maybe_owned();
+        let mo = path.display().as_cow();
         assert_eq!(mo.as_slice(), "foo");
         let path = Path::new(b"\\");
-        let mo = path.filename_display().as_maybe_owned();
+        let mo = path.filename_display().as_cow();
         assert_eq!(mo.as_slice(), "");
     }
 
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index 65f45c3f97e..756ff1c58f3 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -58,6 +58,7 @@
 
 #[doc(no_inline)] pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr};
 #[doc(no_inline)] pub use ascii::IntoBytes;
+#[doc(no_inline)] pub use borrow::IntoCow;
 #[doc(no_inline)] pub use c_str::ToCStr;
 #[doc(no_inline)] pub use char::{Char, UnicodeChar};
 #[doc(no_inline)] pub use clone::Clone;
@@ -78,7 +79,7 @@
 #[doc(no_inline)] pub use result::Result::{Ok, Err};
 #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude};
 #[doc(no_inline)] pub use str::{Str, StrVector, StrPrelude};
-#[doc(no_inline)] pub use str::{IntoMaybeOwned, StrAllocating, UnicodeStrPrelude};
+#[doc(no_inline)] pub use str::{StrAllocating, UnicodeStrPrelude};
 #[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 #[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 #[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 21b4edb6375..872a5452241 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -56,6 +56,7 @@ Several modules in `core` are clients of `rt`:
 
 #![allow(dead_code)]
 
+use borrow::IntoCow;
 use failure;
 use rustrt;
 use os;
@@ -113,7 +114,6 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
     use prelude::*;
     use rt;
     use rustrt::task::Task;
-    use str;
 
     let something_around_the_top_of_the_stack = 1;
     let addr = &something_around_the_top_of_the_stack as *const int;
@@ -147,7 +147,7 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int {
     let mut main = Some(main);
     let mut task = box Task::new(Some((my_stack_bottom, my_stack_top)),
                                  Some(rustrt::thread::main_guard_page()));
-    task.name = Some(str::Slice("<main>"));
+    task.name = Some("<main>".into_cow());
     drop(task.run(|| {
         unsafe {
             rustrt::stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top);
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();
     }