about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-06-30 16:41:30 +0200
committerAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-07-15 19:55:17 +0200
commit211f1caa290d83a3e24ad99d53395975a3981014 (patch)
tree717e8a9d5debccefacc275fdd28f6a292a5737be /src/libstd
parent1704ebb798bd55a782b80ae6741c5d11403aaf13 (diff)
downloadrust-211f1caa290d83a3e24ad99d53395975a3981014.tar.gz
rust-211f1caa290d83a3e24ad99d53395975a3981014.zip
Deprecate `str::from_utf8_owned`
Use `String::from_utf8` instead

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ascii.rs2
-rw-r--r--src/libstd/fmt.rs2
-rw-r--r--src/libstd/io/fs.rs4
-rw-r--r--src/libstd/io/mod.rs12
-rw-r--r--src/libstd/io/process.rs13
-rw-r--r--src/libstd/rt/backtrace.rs2
6 files changed, 15 insertions, 20 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index 796147ce7a0..93f026c76f9 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -438,7 +438,7 @@ unsafe fn str_map_bytes(string: String, map: &'static [u8]) -> String {
         *b = map[*b as uint];
     }
 
-    String::from_str(str::from_utf8(bytes.as_slice()).unwrap())
+    String::from_utf8(bytes).unwrap()
 }
 
 #[inline]
diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs
index 5834e576b08..aacf1232df5 100644
--- a/src/libstd/fmt.rs
+++ b/src/libstd/fmt.rs
@@ -464,7 +464,7 @@ pub use core::fmt::{secret_pointer};
 pub fn format(args: &Arguments) -> string::String{
     let mut output = io::MemWriter::new();
     let _ = write!(&mut output, "{}", args);
-    str::from_utf8(output.unwrap().as_slice()).unwrap().into_string()
+    String::from_utf8(output.unwrap()).unwrap()
 }
 
 impl<'a> Writer for Formatter<'a> {
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index caff7d5e4c5..d49c56b4704 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -999,9 +999,9 @@ mod test {
             let mut read_buf = [0, .. 1028];
             let read_str = match check!(read_stream.read(read_buf)) {
                 -1|0 => fail!("shouldn't happen"),
-                n => str::from_utf8(read_buf.slice_to(n)).unwrap().to_owned()
+                n => str::from_utf8(read_buf.slice_to(n)).unwrap().to_string()
             };
-            assert_eq!(read_str, message.to_owned());
+            assert_eq!(read_str.as_slice(), message);
         }
         check!(unlink(filename));
     })
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 6ac092fd8c6..0df2bb0f57c 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -705,9 +705,9 @@ pub trait Reader {
     /// UTF-8 bytes.
     fn read_to_string(&mut self) -> IoResult<String> {
         self.read_to_end().and_then(|s| {
-            match str::from_utf8(s.as_slice()) {
-                Some(s) => Ok(String::from_str(s)),
-                None => Err(standard_error(InvalidInput)),
+            match String::from_utf8(s) {
+                Ok(s)  => Ok(s),
+                Err(_) => Err(standard_error(InvalidInput)),
             }
         })
     }
@@ -1440,9 +1440,9 @@ pub trait Buffer: Reader {
     /// valid UTF-8 sequence of bytes.
     fn read_line(&mut self) -> IoResult<String> {
         self.read_until('\n' as u8).and_then(|line|
-            match str::from_utf8(line.as_slice()) {
-                Some(s) => Ok(String::from_str(s)),
-                None => Err(standard_error(InvalidInput)),
+            match String::from_utf8(line) {
+                Ok(s)  => Ok(s),
+                Err(_) => Err(standard_error(InvalidInput)),
             }
         )
     }
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index 07574b72645..bc0140a358c 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -813,8 +813,7 @@ mod tests {
         use os;
         let prog = pwd_cmd().spawn().unwrap();
 
-        let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_string();
+        let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap();
         let parent_dir = os::getcwd();
         let child_dir = Path::new(output.as_slice().trim());
 
@@ -832,8 +831,7 @@ mod tests {
         let parent_dir = os::getcwd().dir_path();
         let prog = pwd_cmd().cwd(&parent_dir).spawn().unwrap();
 
-        let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_string();
+        let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap();
         let child_dir = Path::new(output.as_slice().trim().into_string());
 
         let parent_stat = parent_dir.stat().unwrap();
@@ -867,8 +865,7 @@ mod tests {
         if running_on_valgrind() { return; }
 
         let prog = env_cmd().spawn().unwrap();
-        let output = str::from_utf8(prog.wait_with_output().unwrap()
-                                        .output.as_slice()).unwrap().to_string();
+        let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
@@ -884,9 +881,7 @@ mod tests {
         if running_on_valgrind() { return; }
 
         let mut prog = env_cmd().spawn().unwrap();
-        let output = str::from_utf8(prog.wait_with_output()
-                                        .unwrap().output.as_slice())
-                                   .unwrap().to_string();
+        let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap();
 
         let r = os::env();
         for &(ref k, ref v) in r.iter() {
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 09922b5ad76..fa9bf5d9bb6 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -997,7 +997,7 @@ mod test {
     macro_rules! t( ($a:expr, $b:expr) => ({
         let mut m = MemWriter::new();
         super::demangle(&mut m, $a).unwrap();
-        assert_eq!(str::from_utf8(m.unwrap().as_slice()).unwrap().to_owned(), $b.to_owned());
+        assert_eq!(String::from_utf8(m.unwrap()).unwrap(), $b.to_string());
     }) )
 
     #[test]