mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-27 03:30:25 +00:00
Implemented Path::file_stem
This commit is contained in:
parent
a6e1abecfc
commit
28e936f6fe
1 changed files with 26 additions and 0 deletions
|
@ -224,6 +224,32 @@ impl Path {
|
||||||
self.inner.file_name()
|
self.inner.file_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extracts the stem (non-extension) portion of [`self.file_name`].
|
||||||
|
///
|
||||||
|
/// [`self.file_name`]: struct.Path.html#method.file_name
|
||||||
|
///
|
||||||
|
/// The stem is:
|
||||||
|
///
|
||||||
|
/// * [`None`], if there is no file name;
|
||||||
|
/// * The entire file name if there is no embedded `.`;
|
||||||
|
/// * The entire file name if the file name begins with `.` and has no other `.`s within;
|
||||||
|
/// * Otherwise, the portion of the file name before the final `.`
|
||||||
|
///
|
||||||
|
/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use async_std::path::Path;
|
||||||
|
///
|
||||||
|
/// let path = Path::new("foo.rs");
|
||||||
|
///
|
||||||
|
/// assert_eq!("foo", path.file_stem().unwrap());
|
||||||
|
/// ```
|
||||||
|
pub fn file_stem(&self) -> Option<&OsStr> {
|
||||||
|
self.inner.file_stem()
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
|
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
|
||||||
/// allocating.
|
/// allocating.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue