one more Path::with_extension example, to demonstrate behavior

This commit is contained in:
Tshepang Lekhonkhobe 2020-07-20 12:25:12 +02:00 committed by David Tolnay
parent 05630b06fd
commit 83094ea11a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 3 additions and 0 deletions

View File

@ -2244,6 +2244,9 @@ impl Path {
///
/// 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 {