about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-07-10 18:21:16 +0200
committerAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-07-15 19:55:21 +0200
commitc6b82c7566a2e1da7d0f1697335b47c8c999720e (patch)
treee2d131432e0f2ad7d1fe56a846feeab03df1791a /src/libstd
parent1900abdd9b5b5eef5d90b43555c1ae06743e50db (diff)
downloadrust-c6b82c7566a2e1da7d0f1697335b47c8c999720e.tar.gz
rust-c6b82c7566a2e1da7d0f1697335b47c8c999720e.zip
Deprecate `str::from_utf8_lossy`
Use `String::from_utf8_lossy` instead

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/process.rs11
-rw-r--r--src/libstd/os.rs14
-rw-r--r--src/libstd/path/mod.rs4
3 files changed, 14 insertions, 15 deletions
diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs
index bc0140a358c..1f18200f5aa 100644
--- a/src/libstd/io/process.rs
+++ b/src/libstd/io/process.rs
@@ -313,7 +313,6 @@ impl Command {
     ///
     /// ```
     /// use std::io::Command;
-    /// use std::str;
     ///
     /// let output = match Command::new("cat").arg("foot.txt").output() {
     ///     Ok(output) => output,
@@ -321,8 +320,8 @@ impl Command {
     /// };
     ///
     /// println!("status: {}", output.status);
-    /// println!("stdout: {}", str::from_utf8_lossy(output.output.as_slice()));
-    /// println!("stderr: {}", str::from_utf8_lossy(output.error.as_slice()));
+    /// println!("stdout: {}", String::from_utf8_lossy(output.output.as_slice()));
+    /// println!("stderr: {}", String::from_utf8_lossy(output.error.as_slice()));
     /// ```
     pub fn output(&self) -> IoResult<ProcessOutput> {
         self.spawn().and_then(|p| p.wait_with_output())
@@ -353,9 +352,9 @@ impl fmt::Show for Command {
     /// non-utf8 data is lossily converted using the utf8 replacement
     /// character.
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{}", str::from_utf8_lossy(self.program.as_bytes_no_nul())));
+        try!(write!(f, "{}", String::from_utf8_lossy(self.program.as_bytes_no_nul())));
         for arg in self.args.iter() {
-            try!(write!(f, " '{}'", str::from_utf8_lossy(arg.as_bytes_no_nul())));
+            try!(write!(f, " '{}'", String::from_utf8_lossy(arg.as_bytes_no_nul())));
         }
         Ok(())
     }
@@ -903,7 +902,7 @@ mod tests {
         let new_env = vec![("RUN_TEST_NEW_ENV", "123")];
         let prog = env_cmd().env_set_all(new_env.as_slice()).spawn().unwrap();
         let result = prog.wait_with_output().unwrap();
-        let output = str::from_utf8_lossy(result.output.as_slice()).into_string();
+        let output = String::from_utf8_lossy(result.output.as_slice()).into_string();
 
         assert!(output.as_slice().contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 9537d5daca0..11b787f0b9a 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -208,7 +208,7 @@ fn with_env_lock<T>(f: || -> T) -> T {
 /// Returns a vector of (variable, value) pairs, for all the environment
 /// variables of the current process.
 ///
-/// Invalid UTF-8 bytes are replaced with \uFFFD. See `str::from_utf8_lossy()`
+/// Invalid UTF-8 bytes are replaced with \uFFFD. See `String::from_utf8_lossy()`
 /// for details.
 ///
 /// # Example
@@ -223,8 +223,8 @@ fn with_env_lock<T>(f: || -> T) -> T {
 /// ```
 pub fn env() -> Vec<(String,String)> {
     env_as_bytes().move_iter().map(|(k,v)| {
-        let k = String::from_str(str::from_utf8_lossy(k.as_slice()).as_slice());
-        let v = String::from_str(str::from_utf8_lossy(v.as_slice()).as_slice());
+        let k = String::from_utf8_lossy(k.as_slice()).into_string();
+        let v = String::from_utf8_lossy(v.as_slice()).into_string();
         (k,v)
     }).collect()
 }
@@ -316,7 +316,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
 /// None if the variable isn't set.
 ///
 /// Any invalid UTF-8 bytes in the value are replaced by \uFFFD. See
-/// `str::from_utf8_lossy()` for details.
+/// `String::from_utf8_lossy()` for details.
 ///
 /// # Failure
 ///
@@ -334,7 +334,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>,Vec<u8>)> {
 /// }
 /// ```
 pub fn getenv(n: &str) -> Option<String> {
-    getenv_as_bytes(n).map(|v| String::from_str(str::from_utf8_lossy(v.as_slice()).as_slice()))
+    getenv_as_bytes(n).map(|v| String::from_utf8_lossy(v.as_slice()).into_string())
 }
 
 #[cfg(unix)]
@@ -1186,7 +1186,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
 fn real_args() -> Vec<String> {
     real_args_as_bytes().move_iter()
                         .map(|v| {
-                            str::from_utf8_lossy(v.as_slice()).into_string()
+                            String::from_utf8_lossy(v.as_slice()).into_string()
                         }).collect()
 }
 
@@ -1244,7 +1244,7 @@ extern "system" {
 /// via the command line).
 ///
 /// The arguments are interpreted as utf-8, with invalid bytes replaced with \uFFFD.
-/// See `str::from_utf8_lossy` for details.
+/// See `String::from_utf8_lossy` for details.
 /// # Example
 ///
 /// ```rust
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 7d814df8ebf..ececfab5f74 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -72,7 +72,7 @@ use fmt;
 use iter::Iterator;
 use option::{Option, None, Some};
 use str;
-use str::{MaybeOwned, Str, StrSlice, from_utf8_lossy};
+use str::{MaybeOwned, Str, StrSlice};
 use string::String;
 use slice::Vector;
 use slice::{ImmutableEqVector, ImmutableVector};
@@ -483,7 +483,7 @@ impl<'a, P: GenericPath> Display<'a, P> {
     /// unicode replacement char. This involves allocation.
     #[inline]
     pub fn as_maybe_owned(&self) -> MaybeOwned<'a> {
-        from_utf8_lossy(if self.filename {
+        String::from_utf8_lossy(if self.filename {
             match self.path.filename() {
                 None => &[],
                 Some(v) => v