diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-04-14 10:55:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-04-14 10:55:44 -0700 |
| commit | e8ca9a6dd016779727667d6eb335ea89f36d155c (patch) | |
| tree | fba838697da58f0956dd26029e800e6e2e5edc1e /src/libstd | |
| parent | 5780fc11455af963c4f669d0a5f58e44c5068e87 (diff) | |
| parent | 912a872d3c7e12a5d9784c3bfd4cd3c911e468d9 (diff) | |
| download | rust-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.rs | 3 |
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 { |
