Skip to content

Commit 36caecf

Browse files
authored
Rollup merge of rust-lang#84709 - joshtriplett:doc-alias-chdir, r=dtolnay
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.
2 parents c037962 + c185f08 commit 36caecf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/std/src/env.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub fn current_dir() -> io::Result<PathBuf> {
6161
/// assert!(env::set_current_dir(&root).is_ok());
6262
/// println!("Successfully changed working directory to {}!", root.display());
6363
/// ```
64+
#[doc(alias = "chdir")]
6465
#[stable(feature = "env", since = "1.0.0")]
6566
pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
6667
os_imp::chdir(path.as_ref())

0 commit comments

Comments
 (0)