Skip to content

Commit 912a872

Browse files
committed
Fixed with_extension documentation bug
It was mistakenly calling it with "foo.txt" instead of "txt". I've also added an assert.
1 parent 5afa270 commit 912a872

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libstd/path.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,8 @@ impl Path {
15741574
///
15751575
/// let path = Path::new("/tmp/foo.rs");
15761576
///
1577-
/// let new_path = path.with_extension("foo.txt");
1577+
/// let new_path = path.with_extension("txt");
1578+
/// assert_eq!(new_path, PathBuf::from("/tmp/foo.txt"));
15781579
/// ```
15791580
#[stable(feature = "rust1", since = "1.0.0")]
15801581
pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {

0 commit comments

Comments
 (0)