@@ -341,25 +341,30 @@ pub fn relativize_with_prefix<'a>(relative_path: &'a Path, prefix: &Path) -> Cow
341
341
}
342
342
}
343
343
344
- /// The error used in [`ToPathComponents::to_components()`][crate::convert::ToPathComponents::to_components()].
345
- #[ derive( Debug , thiserror:: Error ) ]
346
- #[ allow( missing_docs) ]
347
- pub enum Error < ' a > {
348
- #[ error( "Input path {path:?} contains relative or absolute components" , path = . 0 ) ]
349
- NotANormalComponent ( & ' a OsStr ) ,
344
+ ///
345
+ pub mod to_normal_path_components {
346
+ use std:: ffi:: OsStr ;
347
+
348
+ /// The error used in [`ToNormalPathComponents::to_normal_path_components()`](crate::ToNormalPathComponents::to_normal_path_components()).
349
+ #[ derive( Debug , thiserror:: Error ) ]
350
+ #[ allow( missing_docs) ]
351
+ pub enum Error < ' a > {
352
+ #[ error( "Input path {path:?} contains relative or absolute components" , path = . 0 ) ]
353
+ NotANormalComponent ( & ' a OsStr ) ,
354
+ }
350
355
}
351
356
352
- /// Obtain an iterator over `OsStr`-components.
353
- pub trait ToPathComponents {
354
- /// Return an iterator over the components of a path, without the separator.
355
- fn to_components ( & self ) -> impl Iterator < Item = Result < & OsStr , Error < ' _ > > > ;
357
+ /// Obtain an iterator over `OsStr`-components which are normal, none-relative and not absolute .
358
+ pub trait ToNormalPathComponents {
359
+ /// Return an iterator over the normal components of a path, without the separator.
360
+ fn to_normal_path_components ( & self ) -> impl Iterator < Item = Result < & OsStr , to_normal_path_components :: Error < ' _ > > > ;
356
361
}
357
362
358
- impl ToPathComponents for & Path {
359
- fn to_components ( & self ) -> impl Iterator < Item = Result < & OsStr , Error < ' _ > > > {
363
+ impl ToNormalPathComponents for & Path {
364
+ fn to_normal_path_components ( & self ) -> impl Iterator < Item = Result < & OsStr , to_normal_path_components :: Error < ' _ > > > {
360
365
self . components ( ) . map ( |component| match component {
361
366
Component :: Normal ( os_str) => Ok ( os_str) ,
362
- _ => Err ( Error :: NotANormalComponent ( self . as_os_str ( ) ) ) ,
367
+ _ => Err ( to_normal_path_components :: Error :: NotANormalComponent ( self . as_os_str ( ) ) ) ,
363
368
} )
364
369
}
365
370
}
0 commit comments