File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -186,14 +186,24 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
186186 if result == 0 { Ok ( ( ) ) } else { Err ( io:: Error :: last_os_error ( ) ) }
187187}
188188
189- pub type SplitPaths < ' a > = impl Iterator < Item = PathBuf > ;
189+ // This can't just be `impl Iterator` because that requires `'a` to be live on
190+ // drop (see #146045).
191+ pub type SplitPaths < ' a > = iter:: Map <
192+ slice:: Split < ' a , u8 , impl FnMut ( & u8 ) -> bool + ' static > ,
193+ impl FnMut ( & [ u8 ] ) -> PathBuf + ' static ,
194+ > ;
190195
191196#[ define_opaque( SplitPaths ) ]
192197pub fn split_paths ( unparsed : & OsStr ) -> SplitPaths < ' _ > {
193- unparsed
194- . as_bytes ( )
195- . split ( |& b| b == PATH_SEPARATOR )
196- . map ( |part| PathBuf :: from ( OsStr :: from_bytes ( part) ) )
198+ fn is_separator ( & b: & u8 ) -> bool {
199+ b == PATH_SEPARATOR
200+ }
201+
202+ fn into_pathbuf ( part : & [ u8 ] ) -> PathBuf {
203+ PathBuf :: from ( OsStr :: from_bytes ( part) )
204+ }
205+
206+ unparsed. as_bytes ( ) . split ( is_separator) . map ( into_pathbuf)
197207}
198208
199209#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments