about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-14 10:55:44 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-14 10:55:44 -0700
commite8ca9a6dd016779727667d6eb335ea89f36d155c (patch)
treefba838697da58f0956dd26029e800e6e2e5edc1e /src/libstd
parent5780fc11455af963c4f669d0a5f58e44c5068e87 (diff)
parent912a872d3c7e12a5d9784c3bfd4cd3c911e468d9 (diff)
downloadrust-e8ca9a6dd016779727667d6eb335ea89f36d155c.tar.gz
rust-e8ca9a6dd016779727667d6eb335ea89f36d155c.zip
rollup merge of #24342: tbelaire/patch-1
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 4471b5afa84..9215c93ca1c 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -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 {