about summary refs log tree commit diff
path: root/src/libstd/path.rs
AgeCommit message (Collapse)AuthorLines
2019-01-10make note of one more normalization that Paths doSteve Klabnik-0/+2
Fixes #29008
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-21Fix feature gate to point to 1.32.0 for `path_from_str`Otavio Salvador-1/+1
When the feature has been added back (#55148) the feature gate has not been adjusted accordingly. We have it enabled for 1.32.0, currently in Beta, so adjust it. Refs: #44431. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-25/+25
2018-12-04Add extra comment slashBastian Gruber-1/+1
2018-11-21Remove trailing whitespaceBastian Gruber-1/+1
2018-11-21Adjust doc commentsBastian Gruber-21/+10
2018-11-21Update style of commentsBastian Gruber-14/+26
2018-11-21Update commentsBastian Gruber-4/+2
2018-11-21Remove 'unsafe' commentsBastian Gruber-3/+0
2018-11-21Document `From` implementationsBastian Gruber-0/+24
2018-10-17Implement FromStr for PathBufSimon Sapin-0/+11
Initially landed in https://github.com/rust-lang/rust/pull/48292 and reverted in https://github.com/rust-lang/rust/pull/50401. This time, use `std::string::ParseError` as suggested in https://github.com/rust-lang/rust/issues/44431#issuecomment-428112632
2018-08-11Add links to std::char::REPLACEMENT_CHARACTER from docs.Corey Farwell-1/+3
There are a few places where we mention the replacement character in the docs, and it could be helpful for users to utilize the constant which is available in the standard library, so let’s link to it!
2018-07-23libstd: Prefer `Option::map`/etc over `match` where applicableColin Wallace-4/+1
2018-07-21TypoFelix Rabe-1/+1
2018-07-06impl Clone for Box<CStr>, Box<OsStr>, Box<Path>Matt Brubeck-0/+8
Implements #51908.
2018-06-18Stabilize std::path::Path:ancestorsTobias Stolzmann-8/+4
2018-05-17Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichtonkennytm-0/+16
Implement From for more types on Cow This is basically https://github.com/rust-lang/rust/pull/48191, except that it should be implemented in a way that doesn't break third party crates.
2018-05-12Rollup merge of #50602 - Screwtapello:update-canonicalize-docs, r=cramertjMark Simulacrum-2/+2
Update canonicalize docs I was recently working with file-paths in Rust, and I felt let down by the `std::fs::canonicalize` docs, so I figured I should submit a PR with some suggestions. I was looking for a method to turn a relative path into an absolute path. The `canonicalize` docs didn't mention the words "relative" or "absolute", but they did mention resolving symlinks (which is a kind of canonicalisation and does not imply converting to absolute), so I assumed that's all it did. To remedy this, I've added the word "absolute" to the description of both `std::fs::canonicalize` and `std::path::Path::canonicalize`. After calling `canonicalize` on Windows, I ran into a bunch of other problems I would not have expected from the function's behaviour on Linux. Specifically, if you call `canonicalize` on a path: - it's allowed to be much longer than it otherwise would - `.join("a/slash/delimited/path")` gives you a broken path that Windows can't use, where the same operation would have worked perfectly without `canonicalize` (if the path were short enough) - the resulting path may confuse other Windows programs if you pass it to them on the command-line, or write it to a config file that they read, etc. ...so I tried to summarize those behaviours too. If I understand correctly, those behaviours are a side-effect of calling `GetFinalPathNameByHandle`, and the documentation says `canonicalize` might not call that function in future, so maybe those side-effects shouldn't be part of the function's documentation. However, I bet there's a lot of applications deliberately calling `canonicalize` just for the path-length-extension alone, so that particular side-effect is de-facto part of the `canonicalize` interface.
2018-05-10Mention that fs::canonicalize makes paths absolute.Tim Allen-2/+2
2018-05-09Update features to 1.28.0George Burton-2/+2
2018-05-09use fmt::Result where applicableAndre Bogus-1/+1
2018-05-02Revert "Implement FromStr for PathBuf"Alex Crichton-27/+0
This reverts commit 05a9acc3b844ff284a3e3d85dde2d9798abfb215.
2018-04-27Update the stable attributes to use the current nightly version numberGeorge Burton-2/+2
2018-04-27Add pathbuf_from_cow_pathGeorge Burton-0/+8
2018-04-24Auto merge of #48989 - ExpHP:path-prefix, r=dtolnaybors-9/+11
Make signature of Path::strip_prefix accept non-references I did this a while back but didn't submit a PR. Might as well see what happens. Fixes #48390. **Note: This has the potential to cause regressions in type inference.** However, in order for code to break, it would need to be relying on the signature to determine that a type is `&_`, while still being able to figure out what the `_` is. I'm having a hard time imagining such a scenario in real code.
2018-04-22Implement From for more types on CowGeorge Burton-0/+8
2018-03-17elide elidable lifetime in Path::strip_prefixMichael Lamparski-4/+4
2018-03-08Rollup merge of #48292 - topecongiro:from_str-for-path-and-pathbuf, ↵Manish Goregaokar-0/+27
r=alexcrichton Implement FromStr for PathBuf Closes #44431.
2018-03-06Implement FromStr for PathBuftopecongiro-0/+27
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-3/+3
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-2/+2
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-02-28Add std::path::Path::ancestorsTobias Stolzmann-0/+75
Squashed commit of the following: commit 1b5d55e26f667b1a25c83c5db0cbb072013a5122 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Wed Feb 28 00:06:15 2018 +0100 Bugfix commit 4265c2db0b0aaa66fdeace5d329665fd2d13903a Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Tue Feb 27 22:59:12 2018 +0100 Rename std::path::Path::parents into std::path::Path::ancestors commit 2548e4b14d377d20adad0f08304a0dd6f8e48e23 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Tue Feb 27 12:50:37 2018 +0100 Add tracking issue commit 3e2ce51a6eea0e39af05849f76dd2cefd5035e86 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Mon Feb 26 15:05:15 2018 +0100 impl FusedIterator for Parents commit a7e096420809740311e19d963d4aba6df77be2f9 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Mon Feb 26 14:38:41 2018 +0100 Clarify that the iterator returned will yield at least one value commit 796a36ea203cd197cc4c810eebd21c7e3433e6f1 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Thu Feb 22 14:01:21 2018 +0100 Fix examples commit e279383b21f11c97269cb355a5b2a0ecdb65bb0c Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Thu Feb 22 04:47:24 2018 +0100 Add std::path::Path::parents
2018-02-24Fix capitalisation in Path#file_name's docsDale Wijnand-1/+1
2018-02-20Make signature of Path::strip_prefix un-bizarreMichael Lamparski-8/+10
BREAKING CHANGE: This has the potential to cause regressions in type inference.
2018-02-10Correct a few stability attributesOliver Middleton-1/+1
2018-01-18Add some edge cases to the documentation of `Path`Tobias Bucher-0/+7
Affected methods are `starts_with` and `strip_prefix`.
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-0/+1
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-13Rollup merge of #46985 - Diggsey:path-component-asref, r=alexcrichtonkennytm-0/+7
Implement AsRef<Path> for Component Fixes #41866
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-0/+1
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2017-12-28Implement AsRef<Path> for ComponentDiggory Blake-0/+7
2017-12-27Correct a few stability attributesOliver Middleton-4/+4
2017-11-25Implement `Rc`/`Arc` conversions for string-like typesMurarth-0/+58
Provides the following conversion implementations: * `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>` * `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>` * `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-21fix some typosMartin Lindhe-1/+1
2017-11-13Rollup merge of #45892 - redox-os:is_absolute_fix, r=alexcrichtonkennytm-4/+4
Redox: Return true from Path::is_absolute if a Path contains root or a scheme In Redox, different subsystems have different filesystem paths. However, the majority of applications using the `Path::is_absolute` function really only want to know if a path is absolute from the perspective of the scheme it is currently running in, usually `file:`. This makes both `file:/` and `/` return `true` from `Path::is_absolute`, meaning that most code does not have to check if it is running on Redox. Code that wants to know if a path contains a scheme can implement such a check on its own. Related to https://github.com/rust-lang/rust/pull/45893
2017-11-04Allow absolute if either contains root or a schemeJeremy Soller-4/+4
2017-11-03Copy `AsciiExt` methods to `char` directlyLukas Kalbertodt-1/+0
This is done in order to deprecate AsciiExt eventually.
2017-09-28Fix errors in Box<Path> conversionsNikolai Vazquez-2/+4
2017-09-28Remove unused 'mem' import in 'path' moduleNikolai Vazquez-1/+0
2017-09-28Remove mem::transmute used in Path conversionsNikolai Vazquez-8/+9