]> git.lizzy.rs Git - rust.git/commitdiff
one more Path::with_extension example, to demonstrate behavior
authorTshepang Lekhonkhobe <tshepang@gmail.com>
Mon, 20 Jul 2020 10:25:12 +0000 (12:25 +0200)
committerDavid Tolnay <dtolnay@gmail.com>
Wed, 22 Jul 2020 23:39:45 +0000 (16:39 -0700)
src/libstd/path.rs

index f14a9ff72f62f473ef8437ed5c63650cbab30785..392c815ef2803a5002d03564d49e5f330c55e884 100644 (file)
@@ -2244,6 +2244,9 @@ fn _with_file_name(&self, file_name: &OsStr) -> PathBuf {
     ///
     /// let path = Path::new("foo.rs");
     /// assert_eq!(path.with_extension("txt"), PathBuf::from("foo.txt"));
+    ///
+    /// let path = Path::new("foo.tar.gz");
+    /// assert_eq!(path.with_extension(""), PathBuf::from("foo.tar"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {