mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Add basename and dirname aliases
This commit is contained in:
parent
1a7c203e7f
commit
61519b8cf1
@ -1670,6 +1670,7 @@ impl DirEntry {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[doc(alias = "basename")]
|
||||||
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
|
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
|
||||||
pub fn file_name(&self) -> OsString {
|
pub fn file_name(&self) -> OsString {
|
||||||
self.0.file_name()
|
self.0.file_name()
|
||||||
|
@ -2158,6 +2158,7 @@ impl Path {
|
|||||||
/// assert_eq!(grand_parent.parent(), None);
|
/// assert_eq!(grand_parent.parent(), None);
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[doc(alias = "dirname")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn parent(&self) -> Option<&Path> {
|
pub fn parent(&self) -> Option<&Path> {
|
||||||
let mut comps = self.components();
|
let mut comps = self.components();
|
||||||
@ -2225,6 +2226,7 @@ impl Path {
|
|||||||
/// assert_eq!(None, Path::new("/").file_name());
|
/// assert_eq!(None, Path::new("/").file_name());
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
#[doc(alias = "basename")]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn file_name(&self) -> Option<&OsStr> {
|
pub fn file_name(&self) -> Option<&OsStr> {
|
||||||
self.components().next_back().and_then(|p| match p {
|
self.components().next_back().and_then(|p| match p {
|
||||||
|
Loading…
Reference in New Issue
Block a user