diff options
Diffstat (limited to 'src/libstd/path')
| -rw-r--r-- | src/libstd/path/posix.rs | 22 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 20 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index eceeb73a015..d69e9b448be 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -29,12 +29,14 @@ use super::{BytesContainer, GenericPath, GenericPathUnsafe}; /// Iterator that yields successive components of a Path as &[u8] pub type Components<'a> = Splits<'a, u8>; /// Iterator that yields components of a Path in reverse as &[u8] +#[deprecated = "replaced by Rev<Components<'a>>"] pub type RevComponents<'a> = Rev<Components<'a>>; /// Iterator that yields successive components of a Path as Option<&str> pub type StrComponents<'a> = Map<'a, &'a [u8], Option<&'a str>, Components<'a>>; /// Iterator that yields components of a Path in reverse as Option<&str> +#[deprecated = "replaced by Rev<StrComponents<'a>>"] pub type RevStrComponents<'a> = Rev<StrComponents<'a>>; /// Represents a POSIX file path @@ -307,8 +309,8 @@ impl GenericPath for Path { fn ends_with_path(&self, child: &Path) -> bool { if !child.is_relative() { return false; } - let mut selfit = self.rev_components(); - let mut childit = child.rev_components(); + let mut selfit = self.components().rev(); + let mut childit = child.components().rev(); loop { match (selfit.next(), childit.next()) { (Some(a), Some(b)) => if a != b { return false; }, @@ -395,7 +397,8 @@ impl Path { /// Returns an iterator that yields each component of the path in reverse. /// See components() for details. - pub fn rev_components<'a>(&'a self) -> RevComponents<'a> { + #[deprecated = "replaced by .components().rev()"] + pub fn rev_components<'a>(&'a self) -> Rev<Components<'a>> { self.components().rev() } @@ -407,7 +410,8 @@ impl Path { /// Returns an iterator that yields each component of the path in reverse as Option<&str>. /// See components() for details. - pub fn rev_str_components<'a>(&'a self) -> RevStrComponents<'a> { + #[deprecated = "replaced by .str_components().rev()"] + pub fn rev_str_components<'a>(&'a self) -> Rev<StrComponents<'a>> { self.str_components().rev() } } @@ -1183,7 +1187,7 @@ mod tests { let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>(); assert!(comps == exps, "components: Expected {:?}, found {:?}", comps, exps); - let comps = path.rev_components().collect::<Vec<&[u8]>>(); + let comps = path.components().rev().collect::<Vec<&[u8]>>(); let exps = exps.move_iter().rev().collect::<Vec<&[u8]>>(); assert!(comps == exps, "rev_components: Expected {:?}, found {:?}", comps, exps); @@ -1195,8 +1199,8 @@ mod tests { let comps = path.components().collect::<Vec<&[u8]>>(); let exp: &[&[u8]] = [$(b!($($exp),*)),*]; assert_eq!(comps.as_slice(), exp); - let comps = path.rev_components().collect::<Vec<&[u8]>>(); - let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&[u8]>>(); + let comps = path.components().rev().collect::<Vec<&[u8]>>(); + let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); assert_eq!(comps, exp) } ) @@ -1227,8 +1231,8 @@ mod tests { let comps = path.str_components().collect::<Vec<Option<&str>>>(); let exp: &[Option<&str>] = $exp; assert_eq!(comps.as_slice(), exp); - let comps = path.rev_str_components().collect::<Vec<Option<&str>>>(); - let exp = exp.rev_iter().map(|&x|x).collect::<Vec<Option<&str>>>(); + let comps = path.str_components().rev().collect::<Vec<Option<&str>>>(); + let exp = exp.iter().rev().map(|&x|x).collect::<Vec<Option<&str>>>(); assert_eq!(comps, exp); } ) diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 679075fe6ca..758a76167cd 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -37,12 +37,14 @@ pub type StrComponents<'a> = Map<'a, &'a str, Option<&'a str>, /// /// Each component is yielded as Option<&str> for compatibility with PosixPath, but /// every component in WindowsPath is guaranteed to be Some. +#[deprecated = "replaced by Rev<StrComponents<'a>>"] pub type RevStrComponents<'a> = Rev<StrComponents<'a>>; /// Iterator that yields successive components of a Path as &[u8] pub type Components<'a> = Map<'a, Option<&'a str>, &'a [u8], StrComponents<'a>>; /// Iterator that yields components of a Path in reverse as &[u8] +#[deprecated = "replaced by Rev<Components<'a>>"] pub type RevComponents<'a> = Rev<Components<'a>>; /// Represents a Windows path @@ -631,7 +633,8 @@ impl Path { /// Returns an iterator that yields each component of the path in reverse as an Option<&str> /// See str_components() for details. - pub fn rev_str_components<'a>(&'a self) -> RevStrComponents<'a> { + #[deprecated = "replaced by .str_components().rev()"] + pub fn rev_str_components<'a>(&'a self) -> Rev<StrComponents<'a>> { self.str_components().rev() } @@ -647,7 +650,8 @@ impl Path { /// Returns an iterator that yields each component of the path in reverse as a &[u8]. /// See str_components() for details. - pub fn rev_components<'a>(&'a self) -> RevComponents<'a> { + #[deprecated = "replaced by .components().rev()"] + pub fn rev_components<'a>(&'a self) -> Rev<Components<'a>> { self.components().rev() } @@ -2233,9 +2237,9 @@ mod tests { .collect::<Vec<&str>>(); let exp: &[&str] = $exp; assert_eq!(comps.as_slice(), exp); - let comps = path.rev_str_components().map(|x|x.unwrap()) + let comps = path.str_components().rev().map(|x|x.unwrap()) .collect::<Vec<&str>>(); - let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&str>>(); + let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>(); assert_eq!(comps, exp); } ); @@ -2245,9 +2249,9 @@ mod tests { let comps = path.str_components().map(|x|x.unwrap()).collect::<Vec<&str>>(); let exp: &[&str] = $exp; assert_eq!(comps.as_slice(), exp); - let comps = path.rev_str_components().map(|x|x.unwrap()) + let comps = path.str_components().rev().map(|x|x.unwrap()) .collect::<Vec<&str>>(); - let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&str>>(); + let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>(); assert_eq!(comps, exp); } ) @@ -2302,8 +2306,8 @@ mod tests { let comps = path.components().collect::<Vec<&[u8]>>(); let exp: &[&[u8]] = $exp; assert_eq!(comps.as_slice(), exp); - let comps = path.rev_components().collect::<Vec<&[u8]>>(); - let exp = exp.rev_iter().map(|&x|x).collect::<Vec<&[u8]>>(); + let comps = path.components().rev().collect::<Vec<&[u8]>>(); + let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); assert_eq!(comps, exp); } ) |
