about summary refs log tree commit diff
path: root/src/libstd/path.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-4230/+0
2020-07-22one more Path::with_extension example, to demonstrate behaviorTshepang Lekhonkhobe-0/+3
2020-06-27Added the parapgrah to path::Path::is_file tooAlexis Bourget-2/+7
2020-06-27Update the documentation to point to open instead of is_file and is_dirAlexis Bourget-1/+1
2020-06-11Make a note about is_dir vs is_file in Path tooAlexis Bourget-4/+8
2020-05-29Add Extend::{extend_one,extend_reserve}Josh Stone-0/+5
This adds new optional methods on `Extend`: `extend_one` add a single element to the collection, and `extend_reserve` pre-allocates space for the predicted number of incoming elements. These are used in `Iterator` for `partition` and `unzip` as they shuffle elements one-at-a-time into their respective collections.
2020-05-19Auto merge of #71447 - cuviper:unsized_cow, r=dtolnaybors-0/+11
impl From<Cow> for Box, Rc, and Arc These forward `Borrowed`/`Owned` values to existing `From` impls. - `Box<T>` is a fundamental type, so it would be a breaking change to add a blanket impl. Therefore, `From<Cow>` is only implemented for `[T]`, `str`, `CStr`, `OsStr`, and `Path`. - For `Rc<T>` and `Arc<T>`, `From<Cow>` is implemented for everything that implements `From` the borrowed and owned types separately.
2020-05-15Updated documentation of Prefix::VerbatimDiskSOFe-2/+2
PrefixComponent with Prefix::VerbatimDisk does not contain the trailing slash. The documentation here is also inconsistent with the documentation on other variants that reflect the `PrefixComponent::as_os_str()` return value.
2020-04-22impl From<Cow> for boxed slices and stringsJosh Stone-0/+11
These forward `Borrowed`/`Owned` values to existing `Box::from` impls. - `From<Cow<'_, [T]>> for Box<[T]>` - `From<Cow<'_, str>> for Box<str>` - `From<Cow<'_, CStr>> for Box<CStr>` - `From<Cow<'_, OsStr>> for Box<OsStr>` - `From<Cow<'_, Path>> for Box<Path>`
2020-04-19Stabilize PathBuf capacity methodsMark Rousskov-8/+7
2020-02-29remove unneeded .as_ref() calls.Matthias Krüger-1/+1
2020-01-10inline `impl AsRef<Path> for PathBuf`Lzu Tao-0/+1
2020-01-10Inline `impl From<OsString> for PathBuf`Lzu Tao-0/+1
2020-01-10Inline `AsRef<Path> for str`Lzu Tao-0/+1
2020-01-10Inline PathBuf::deref to make it zero costLzu Tao-1/+1
2020-01-08Use matches macro in libcore and libstdIgor Aleksanov-8/+2
2019-12-28Rollup merge of #67635 - Mark-Simulacrum:path-doc-unsafe, r=dtolnayOliver Scherer-0/+7
Document safety of Path casting I would personally feel more comfortable making the relevant (internal anyway) types repr(transparent) and then documenting that we can make these casts because of that, but I believe this is a more minimal PR, so posting it first. Resolves #45910.
2019-12-26Document safety of Path castingMark Rousskov-0/+7
2019-12-26Remove redundant link textsMatthew Kraai-1/+1
2019-12-24Deprecate Error::description for realDavid Tolnay-0/+2
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-11-29Format libstd with rustfmtDavid Tolnay-847/+781
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-10-23Prevent unnecessary allocation in PathBuf::set_extension.Mara Bos-11/+15
It was allocating a new OsString that was immediately dropped after using it with set_file_name. Now it directly changes the extension in the original buffer, without touching the rest of the file name or allocating a temporary string.
2019-10-11Rollup merge of #65266 - rust-lang:must-use-join, r=dtolnayTyler Mandry-0/+1
Mark Path::join as must_use I've accidentally did `mut_path_buf.jon(a_path);`, expecting this to be an in-place modification. Seems like we can easily warn in such cases?
2019-10-10Mark Path::join as must_useAleksey Kladov-0/+1
I've accidentally did `mut_path_buf.jon(a_path);`, expecting this to be an in-place modification. Seems like we can easily warn in such cases?
2019-09-20libstd: Fix typos in docHsiang-Cheng Yang-4/+4
2019-08-11Rollup merge of #61969 - MikailBag:master, r=CentrilMark Rousskov-0/+12
Add #[repr(transparent)] for several types In some functions, types mentioned in this PR are transmuted into their inner value. Example for `PathBuf`: https://github.com/rust-lang/rust/blob/master/src/libstd/path.rs#L1132. This PR adds `#[repr(transparent)]` to those types, so their correct behavior doesn't depend on compiler details. (As far as I understand, currently that line, converting `PathBuf` to `Vec<u8>`, is UB).
2019-08-09Add FIXME-s that some types should be transparentMikail Bagishov-0/+12
2019-08-06redox: convert to target_family unixJeremy Soller-1/+1
2019-08-01Update src/libstd/path.rs to shorten the explanation for .to_str validation stepJason Shin-1/+1
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-08-01Explaining the reason why validation is performed in to_str of path.rsJason Shin-0/+2
2019-05-22Revert "Add implementations of last in terms of next_back on a bunch of ↵Steven Fackler-10/+0
DoubleEndedIterators." This reverts commit 3e86cf36b5114f201868bf459934fe346a76a2d4.
2019-05-14Rollup merge of #60130 - khuey:efficient_last, r=sfacklerMazdak Farrokhzad-0/+10
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators Provided a `DoubleEndedIterator` has finite length, `Iterator::last` is equivalent to `DoubleEndedIterator::next_back`. But searching forwards through the iterator when it's unnecessary is obviously not good for performance. I ran into this on one of the collection iterators. I tried adding appropriate overloads for a bunch of the iterator adapters like filter, map, etc, but I ran into a lot of type inference failures after doing so. The other interesting case is what to do with `Repeat`. Do we consider it part of the contract that `Iterator::last` will loop forever on it? The docs do say that the iterator will be evaluated until it returns None. This is also relevant for the adapters, it's trivially easy to observe whether a `Map` adapter invoked its closure a zillion times or just once for the last element.
2019-04-25ignore-tidy-filelength on all files with greater than 3000 linesvarkor-0/+2
2019-04-19Add implementations of last in terms of next_back on a bunch of ↵Kyle Huey-0/+10
DoubleEndedIterators. r?Manishearth
2019-04-05Use for_each to extend collectionsJosh Stone-3/+1
This updates the `Extend` implementations to use `for_each` for many collections: `BinaryHeap`, `BTreeMap`, `BTreeSet`, `LinkedList`, `Path`, `TokenStream`, `VecDeque`, and `Wtf8Buf`. Folding with `for_each` enables better performance than a `for`-loop for some iterators, especially if they can just forward to internal iterators, like `Chain` and `FlatMap` do.
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-19/+19
2019-03-25SGX target: fix std unit testsJethro Beekman-2/+2
2019-03-09Use lifetime contravariance to elide more lifetimes in core+alloc+stdScott McMurray-6/+6
2019-02-28libstd => 2018Taiki Endo-23/+23
2019-02-25Auto merge of #58302 - SimonSapin:tryfrom, r=alexcrichtonbors-2/+1
Stabilize TryFrom and TryInto with a convert::Infallible empty enum This is the plan proposed in https://github.com/rust-lang/rust/issues/33417#issuecomment-423073898
2019-02-20Rollup merge of #58553 - scottmcm:more-ihle, r=Centrilkennytm-22/+22
Use more impl header lifetime elision Inspired by seeing explicit lifetimes on these two: - https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator - https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not And a follow-up to https://github.com/rust-lang/rust/pull/54687, that started using IHLE in libcore. Most of the changes in here fall into two big categories: - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm). I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-18Fixed doc example for Path::with_capacityAaron Stillwell-1/+2
2019-02-17Use more impl header lifetime elisionScott McMurray-22/+22
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-17Changed feature gate for new PathBuf methodsAaron Stillwell-7/+7
Feature gate changed to `path_buf_capacity` as per advice from @Mark-Simulacrum
2019-02-17Fixes for implementation of PathBuf methods (aliases for OsString)Aaron Stillwell-19/+19
- Fixed incorrect `mut` usage - Fixed style in accordance with tidy - Marked all methods as unstable - Changed feature identifier to path_buf_alias_os_string_methods
2019-02-17Add alias methods to PathBuf for underlying OsStringAaron Stillwell-1/+81
Implemented the following methods on PathBuf which forward to the underlying OsString. - capacity - with_capacity - clear - reserve - reserve_exact - shrink_to_fit - shrink_to
2019-02-15Fix documentation for std::path::PathBuf::popNathan-2/+1
Closes #58474.
2019-02-13Add a convert::Infallible empty enum, make string::ParseError an aliasSimon Sapin-2/+1
2019-02-10libs: doc commentsAlexander Regueiro-3/+3
2019-01-10Update src/libstd/path.rsMazdak Farrokhzad-1/+1
Co-Authored-By: steveklabnik <steve@steveklabnik.com>