diff options
| author | bors <bors@rust-lang.org> | 2017-05-19 20:41:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-05-19 20:41:18 +0000 |
| commit | 5dfcd85fd4bae49445383baadf472fbdb414a0e6 (patch) | |
| tree | 6812e7e07285e77a85e3619139280ca3cd09b0a7 /src/libstd/env.rs | |
| parent | 543691d0ebbbf9e3c996980d2b841794098e5e85 (diff) | |
| parent | 040cd6d15dcc8c1f66726293d52df93abd2e4b76 (diff) | |
| download | rust-5dfcd85fd4bae49445383baadf472fbdb414a0e6.tar.gz rust-5dfcd85fd4bae49445383baadf472fbdb414a0e6.zip | |
Auto merge of #42105 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 17 pull requests - Successful merges: #41870, #41910, #41958, #41971, #42006, #42024, #42037, #42056, #42067, #42070, #42079, #42080, #42082, #42089, #42092, #42096, #42100 - Failed merges:
Diffstat (limited to 'src/libstd/env.rs')
| -rw-r--r-- | src/libstd/env.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 64eb52e28bc..96c10c5d10d 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -43,16 +43,19 @@ use sys::os as os_imp; /// use std::env; /// /// // We assume that we are in a valid directory. -/// let p = env::current_dir().unwrap(); -/// println!("The current directory is {}", p.display()); +/// let path = env::current_dir().unwrap(); +/// println!("The current directory is {}", path.display()); /// ``` #[stable(feature = "env", since = "1.0.0")] pub fn current_dir() -> io::Result<PathBuf> { os_imp::getcwd() } -/// Changes the current working directory to the specified path, returning -/// whether the change was completed successfully or not. +/// Changes the current working directory to the specified path. +/// +/// Returns an [`Err`] if the operation fails. +/// +/// [`Err`]: ../../std/result/enum.Result.html#method.err /// /// # Examples /// @@ -65,8 +68,8 @@ pub fn current_dir() -> io::Result<PathBuf> { /// println!("Successfully changed working directory to {}!", root.display()); /// ``` #[stable(feature = "env", since = "1.0.0")] -pub fn set_current_dir<P: AsRef<Path>>(p: P) -> io::Result<()> { - os_imp::chdir(p.as_ref()) +pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { + os_imp::chdir(path.as_ref()) } /// An iterator over a snapshot of the environment variables of this process. @@ -175,10 +178,10 @@ impl fmt::Debug for VarsOs { /// /// The returned result is [`Ok(s)`] if the environment variable is present and is /// valid unicode. If the environment variable is not present, or it is not -/// valid unicode, then [`Err`] will be returned. +/// valid unicode, then [`VarError`] will be returned. /// /// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok -/// [`Err`]: ../result/enum.Result.html#variant.Err +/// [`VarError`]: enum.VarError.html /// /// # Examples /// @@ -199,7 +202,7 @@ pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> { fn _var(key: &OsStr) -> Result<String, VarError> { match var_os(key) { Some(s) => s.into_string().map_err(VarError::NotUnicode), - None => Err(VarError::NotPresent) + None => Err(VarError::NotPresent), } } |
