diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-11-21 17:10:42 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-11-25 11:22:23 -0500 |
| commit | 3293ab14e24d136d0482bb18afef577aebed251e (patch) | |
| tree | c21d2568d6eaf1cc1835034cf2557277c4e8d58b /src/libstd/path | |
| parent | 48ca6d1840818e4a8977d00ed62cf0e8e0e5d193 (diff) | |
| download | rust-3293ab14e24d136d0482bb18afef577aebed251e.tar.gz rust-3293ab14e24d136d0482bb18afef577aebed251e.zip | |
Deprecate MaybeOwned[Vector] in favor of Cow
Diffstat (limited to 'src/libstd/path')
| -rw-r--r-- | src/libstd/path/mod.rs | 6 | ||||
| -rw-r--r-- | src/libstd/path/posix.rs | 4 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 4 |
3 files changed, 7 insertions, 7 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(), ""); } |
