about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-11 18:59:49 +0200
committerGitHub <noreply@github.com>2022-10-11 18:59:49 +0200
commitccde95f4895ea301073ca723cadc0675617b9c8f (patch)
tree5c94e17b57fcc47ab17d4a0d8bff9be265c8299f
parent1b1223df9fb9c3152d5b5bb60accce08b237f297 (diff)
parentd1762d7a96adbeb4702bcb4486ebf47555bfd01b (diff)
downloadrust-ccde95f4895ea301073ca723cadc0675617b9c8f.tar.gz
rust-ccde95f4895ea301073ca723cadc0675617b9c8f.zip
Rollup merge of #102869 - azdavis:master, r=joshtriplett
Add basename and dirname aliases

Users might be used to the POSIX names of these functions. In fact, here's a [blog post][1] about this very thing.

[1]: https://boinkor.net/2019/07/basename-and-dirname-in-rust/
-rw-r--r--library/std/src/path.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 4f9dff1ef03..9d63281627d 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2158,6 +2158,7 @@ impl Path {
     /// assert_eq!(grand_parent.parent(), None);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[doc(alias = "dirname")]
     #[must_use]
     pub fn parent(&self) -> Option<&Path> {
         let mut comps = self.components();
@@ -2225,6 +2226,7 @@ impl Path {
     /// assert_eq!(None, Path::new("/").file_name());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[doc(alias = "basename")]
     #[must_use]
     pub fn file_name(&self) -> Option<&OsStr> {
         self.components().next_back().and_then(|p| match p {