Rollup merge of #74548 - tshepang:one-more-example, r=dtolnay

one more Path::with_extension example, to demonstrate behavior
This commit is contained in:
Manish Goregaokar 2020-07-23 00:42:10 -07:00 committed by GitHub
commit 5629223782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {