File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -31,17 +31,14 @@ impl Environment {
31
31
/// Changes the current working directory.
32
32
#[ doc( alias( "change" ) ) ]
33
33
pub fn chdir ( & mut self , path : & Path ) -> Result < ( ) > {
34
- for component in path. components ( ) {
35
- let new = self . working_dir . lock ( ) . get ( component. as_ref ( ) ) ;
36
- match new {
37
- Some ( FileOrDir :: Dir ( dir) ) => {
38
- self . working_dir = dir;
39
- }
40
- Some ( FileOrDir :: File ( _) ) => return Err ( Error :: NotADirectory ) ,
41
- None => return Err ( Error :: NotFound ) ,
34
+ match path. get ( & self . working_dir ) {
35
+ Some ( FileOrDir :: Dir ( dir) ) => {
36
+ self . working_dir = dir;
37
+ Ok ( ( ) )
42
38
}
39
+ Some ( FileOrDir :: File ( _) ) => Err ( Error :: NotADirectory ) ,
40
+ None => Err ( Error :: NotFound ) ,
43
41
}
44
- Ok ( ( ) )
45
42
}
46
43
47
44
/// Returns the value of the environment variable with the given `key`.
You can’t perform that action at this time.
0 commit comments