@@ -297,10 +297,9 @@ pub const MAIN_SEPARATOR: char = ::sys::path::MAIN_SEP;
297
297
// Iterate through `iter` while it matches `prefix`; return `None` if `prefix`
298
298
// is not a prefix of `iter`, otherwise return `Some(iter_after_prefix)` giving
299
299
// `iter` after having exhausted `prefix`.
300
- fn iter_after < A , I , J > ( mut iter : I , mut prefix : J ) -> Option < I >
301
- where I : Iterator < Item = A > + Clone ,
302
- J : Iterator < Item = A > ,
303
- A : PartialEq
300
+ fn iter_after < ' a , ' b , I , J > ( mut iter : I , mut prefix : J ) -> Option < I >
301
+ where I : Iterator < Item = Component < ' a > > + Clone ,
302
+ J : Iterator < Item = Component < ' b > > ,
304
303
{
305
304
loop {
306
305
let mut iter_next = iter. clone ( ) ;
@@ -1865,7 +1864,7 @@ impl Path {
1865
1864
/// # Examples
1866
1865
///
1867
1866
/// ```
1868
- /// use std::path::Path;
1867
+ /// use std::path::{ Path, PathBuf} ;
1869
1868
///
1870
1869
/// let path = Path::new("/test/haha/foo.txt");
1871
1870
///
@@ -1876,16 +1875,19 @@ impl Path {
1876
1875
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
1877
1876
/// assert_eq!(path.strip_prefix("test").is_ok(), false);
1878
1877
/// assert_eq!(path.strip_prefix("/haha").is_ok(), false);
1878
+ ///
1879
+ /// let prefix = PathBuf::from("/test/");
1880
+ /// assert_eq!(path.strip_prefix(prefix), Ok(Path::new("haha/foo.txt")));
1879
1881
/// ```
1880
1882
#[ stable( since = "1.7.0" , feature = "path_strip_prefix" ) ]
1881
- pub fn strip_prefix < ' a , P : ? Sized > ( & ' a self , base : & ' a P )
1882
- -> Result < & ' a Path , StripPrefixError >
1883
+ pub fn strip_prefix < ' a , P > ( & ' a self , base : P )
1884
+ -> Result < & ' a Path , StripPrefixError >
1883
1885
where P : AsRef < Path >
1884
1886
{
1885
1887
self . _strip_prefix ( base. as_ref ( ) )
1886
1888
}
1887
1889
1888
- fn _strip_prefix < ' a > ( & ' a self , base : & ' a Path )
1890
+ fn _strip_prefix < ' a > ( & ' a self , base : & Path )
1889
1891
-> Result < & ' a Path , StripPrefixError > {
1890
1892
iter_after ( self . components ( ) , base. components ( ) )
1891
1893
. map ( |c| c. as_path ( ) )
0 commit comments