mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 19:33:16 +00:00
Rollup merge of #74548 - tshepang:one-more-example, r=dtolnay
one more Path::with_extension example, to demonstrate behavior
This commit is contained in:
commit
5629223782
@ -2244,6 +2244,9 @@ impl Path {
|
|||||||
///
|
///
|
||||||
/// let path = Path::new("foo.rs");
|
/// let path = Path::new("foo.rs");
|
||||||
/// assert_eq!(path.with_extension("txt"), PathBuf::from("foo.txt"));
|
/// 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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
|
pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
|
||||||
|
Loading…
Reference in New Issue
Block a user