Skip to content

Commit

Permalink
Rollup merge of rust-lang#24342 - tbelaire:patch-1, r=huonw
Browse files Browse the repository at this point in the history
It was mistakenly calling `with_extension` with "foo.txt" instead of "txt".  
I've also added an assert.  This also calls more attention to the fact you get back a PathBuf, instead of a Path, which I feel is easy to miss when skimming.
  • Loading branch information
Manishearth committed Apr 12, 2015
2 parents f6f3f04 + 912a872 commit c07e16b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,8 @@ impl Path {
///
/// let path = Path::new("/tmp/foo.rs");
///
/// let new_path = path.with_extension("foo.txt");
/// let new_path = path.with_extension("txt");
/// assert_eq!(new_path, PathBuf::from("/tmp/foo.txt"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf {
Expand Down

0 comments on commit c07e16b

Please sign in to comment.