about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-05-05 17:52:20 +0200
committerGitHub <noreply@github.com>2021-05-05 17:52:20 +0200
commit4c4b3e81df7c61b99fe1cef2ac581077e38c7467 (patch)
treeae057254d2178e53d00f6dd74d2b90bad4dfb677
parentd84fcc8b29b45a523cc27791f93405412bcfdac0 (diff)
parentc185f08e467e02c83c940eb63516dcf35be0146b (diff)
downloadrust-4c4b3e81df7c61b99fe1cef2ac581077e38c7467.tar.gz
rust-4c4b3e81df7c61b99fe1cef2ac581077e38c7467.zip
Rollup merge of #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.
-rw-r--r--library/std/src/env.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index 821e7d4cfe7..11d052dae9e 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -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())