File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,32 @@ impl Path {
224
224
self . inner . file_name ( )
225
225
}
226
226
227
+ /// Extracts the stem (non-extension) portion of [`self.file_name`].
228
+ ///
229
+ /// [`self.file_name`]: struct.Path.html#method.file_name
230
+ ///
231
+ /// The stem is:
232
+ ///
233
+ /// * [`None`], if there is no file name;
234
+ /// * The entire file name if there is no embedded `.`;
235
+ /// * The entire file name if the file name begins with `.` and has no other `.`s within;
236
+ /// * Otherwise, the portion of the file name before the final `.`
237
+ ///
238
+ /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
239
+ ///
240
+ /// # Examples
241
+ ///
242
+ /// ```
243
+ /// use async_std::path::Path;
244
+ ///
245
+ /// let path = Path::new("foo.rs");
246
+ ///
247
+ /// assert_eq!("foo", path.file_stem().unwrap());
248
+ /// ```
249
+ pub fn file_stem ( & self ) -> Option < & OsStr > {
250
+ self . inner . file_stem ( )
251
+ }
252
+
227
253
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
228
254
/// allocating.
229
255
///
You can’t perform that action at this time.
0 commit comments