@@ -43,16 +43,19 @@ use sys::os as os_imp;
4343/// use std::env;
4444///
4545/// // 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());
4848/// ```
4949#[ stable( feature = "env" , since = "1.0.0" ) ]
5050pub fn current_dir ( ) -> io:: Result < PathBuf > {
5151 os_imp:: getcwd ( )
5252}
5353
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
5659///
5760/// # Examples
5861///
@@ -65,8 +68,8 @@ pub fn current_dir() -> io::Result<PathBuf> {
6568/// println!("Successfully changed working directory to {}!", root.display());
6669/// ```
6770#[ 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 ( ) )
7073}
7174
7275/// An iterator over a snapshot of the environment variables of this process.
@@ -175,10 +178,10 @@ impl fmt::Debug for VarsOs {
175178///
176179/// The returned result is [`Ok(s)`] if the environment variable is present and is
177180/// 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.
179182///
180183/// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok
181- /// [`Err `]: ../result/ enum.Result .html#variant.Err
184+ /// [`VarError `]: enum.VarError .html
182185///
183186/// # Examples
184187///
@@ -199,7 +202,7 @@ pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> {
199202fn _var ( key : & OsStr ) -> Result < String , VarError > {
200203 match var_os ( key) {
201204 Some ( s) => s. into_string ( ) . map_err ( VarError :: NotUnicode ) ,
202- None => Err ( VarError :: NotPresent )
205+ None => Err ( VarError :: NotPresent ) ,
203206 }
204207}
205208
0 commit comments