about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2014-02-07 14:58:37 -0800
committerKevin Ballard <kevin@sb.org>2014-02-07 22:31:51 -0800
commit28467f5d197d1455e922711a28ea4a19702dbda9 (patch)
treebfcd12c078fb6aa9bbd65053efbbd41d758b7778 /src/libstd/path
parentdde2e0b3865ba040261d2078db371adbefb32506 (diff)
downloadrust-28467f5d197d1455e922711a28ea4a19702dbda9.tar.gz
rust-28467f5d197d1455e922711a28ea4a19702dbda9.zip
Tweak from_utf8_lossy to return a new MaybeOwned enum
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no
invalid bytes in the input.
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 18f28994cba..d5a69b12f2a 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -508,10 +508,10 @@ impl<'a, P: GenericPath> ToStr for Display<'a, P> {
         if self.filename {
             match self.path.filename() {
                 None => ~"",
-                Some(v) => str::from_utf8_lossy(v)
+                Some(v) => str::from_utf8_lossy(v).into_owned()
             }
         } else {
-            str::from_utf8_lossy(self.path.as_vec())
+            str::from_utf8_lossy(self.path.as_vec()).into_owned()
         }
     }
 }