File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -709,6 +709,25 @@ impl Path {
709
709
pub fn to_string_lossy ( & self ) -> std:: borrow:: Cow < ' _ , str > {
710
710
self . inner . to_string_lossy ( )
711
711
}
712
+
713
+ /// Creates an owned [`PathBuf`] like `self` but with the given extension.
714
+ ///
715
+ /// See [`PathBuf::set_extension`] for more details.
716
+ ///
717
+ /// [`PathBuf`]: struct.PathBuf.html
718
+ /// [`PathBuf::set_extension`]: struct.PathBuf.html#method.set_extension
719
+ ///
720
+ /// # Examples
721
+ ///
722
+ /// ```
723
+ /// use async_std::path::{Path, PathBuf};
724
+ ///
725
+ /// let path = Path::new("foo.rs");
726
+ /// assert_eq!(path.with_extension("txt"), PathBuf::from("foo.txt"));
727
+ /// ```
728
+ pub fn with_extension < S : AsRef < OsStr > > ( & self , extension : S ) -> PathBuf {
729
+ self . inner . with_extension ( extension) . into ( )
730
+ }
712
731
}
713
732
714
733
impl < ' a > From < & ' a std:: path:: Path > for & ' a Path {
You can’t perform that action at this time.
0 commit comments