@@ -43,16 +43,19 @@ use sys::os as os_imp;
43
43
/// use std::env;
44
44
///
45
45
/// // We assume that we are in a valid directory.
46
- /// let p = env::current_dir().unwrap();
47
- /// println!("The current directory is {}", p .display());
46
+ /// let path = env::current_dir().unwrap();
47
+ /// println!("The current directory is {}", path .display());
48
48
/// ```
49
49
#[ stable( feature = "env" , since = "1.0.0" ) ]
50
50
pub fn current_dir ( ) -> io:: Result < PathBuf > {
51
51
os_imp:: getcwd ( )
52
52
}
53
53
54
- /// Changes the current working directory to the specified path, returning
55
- /// whether the change was completed successfully or not.
54
+ /// Changes the current working directory to the specified path.
55
+ ///
56
+ /// Returns an [`Err`] if the operation fails.
57
+ ///
58
+ /// [`Err`]: ../../std/result/enum.Result.html#method.err
56
59
///
57
60
/// # Examples
58
61
///
@@ -65,8 +68,8 @@ pub fn current_dir() -> io::Result<PathBuf> {
65
68
/// println!("Successfully changed working directory to {}!", root.display());
66
69
/// ```
67
70
#[ stable( feature = "env" , since = "1.0.0" ) ]
68
- pub fn set_current_dir < P : AsRef < Path > > ( p : P ) -> io:: Result < ( ) > {
69
- os_imp:: chdir ( p . as_ref ( ) )
71
+ pub fn set_current_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ( ) > {
72
+ os_imp:: chdir ( path . as_ref ( ) )
70
73
}
71
74
72
75
/// An iterator over a snapshot of the environment variables of this process.
@@ -175,10 +178,10 @@ impl fmt::Debug for VarsOs {
175
178
///
176
179
/// The returned result is [`Ok(s)`] if the environment variable is present and is
177
180
/// valid unicode. If the environment variable is not present, or it is not
178
- /// valid unicode, then [`Err `] will be returned.
181
+ /// valid unicode, then [`VarError `] will be returned.
179
182
///
180
183
/// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok
181
- /// [`Err `]: ../result/ enum.Result .html#variant.Err
184
+ /// [`VarError `]: enum.VarError .html
182
185
///
183
186
/// # Examples
184
187
///
@@ -199,7 +202,7 @@ pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> {
199
202
fn _var ( key : & OsStr ) -> Result < String , VarError > {
200
203
match var_os ( key) {
201
204
Some ( s) => s. into_string ( ) . map_err ( VarError :: NotUnicode ) ,
202
- None => Err ( VarError :: NotPresent )
205
+ None => Err ( VarError :: NotPresent ) ,
203
206
}
204
207
}
205
208
0 commit comments