Skip to content

Commit

Permalink
Rollup merge of rust-lang#84709 - joshtriplett:doc-alias-chdir, r=dto…
Browse files Browse the repository at this point in the history
…lnay

Add doc alias for `chdir` to `std::env::set_current_dir`

Searching for `chdir` in the Rust documentation produces no useful
results.

I wrote some code recently that called `libc::chdir` and manually
handled errors, because I didn't realize that the safe
`std::env::set_current_dir` existed. I searched for `chdir` and
`change_dir` and `change_directory` (the latter two based on the
precedent of unabbreviating set by `create_dir`), and I also read
through `std::fs` expecting to potentially find it there. Given that
none of those led to `std::env::set_current_dir`, I think that provides
sufficient justification to add this specific alias.
  • Loading branch information
Dylan-DPC committed May 4, 2021
2 parents 5811d9a + c185f08 commit bcadbbc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn current_dir() -> io::Result<PathBuf> {
/// assert!(env::set_current_dir(&root).is_ok());
/// println!("Successfully changed working directory to {}!", root.display());
/// ```
#[doc(alias = "chdir")]
#[stable(feature = "env", since = "1.0.0")]
pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
os_imp::chdir(path.as_ref())
Expand Down

0 comments on commit bcadbbc

Please sign in to comment.