Skip to content

Commit

Permalink
Rollup merge of #102869 - azdavis:master, r=joshtriplett
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
matthiaskrgr committed Oct 11, 2022
2 parents e396b2b + 93fd9af commit 84cdee7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 84cdee7

Please sign in to comment.