about summary refs log tree commit diff
path: root/library/std/src/path.rs
AgeCommit message (Collapse)AuthorLines
2021-10-11Rollup merge of #89729 - jkugelman:must-use-core-std-constructors, ↵Guillaume Gomez-0/+2
r=joshtriplett Add #[must_use] to core and std constructors Parent issue: #89692 r? ``@joshtriplett``
2021-10-10Add #[must_use] to conversions that move selfJohn Kugelman-0/+3
2021-10-10Add #[must_use] to core and std constructorsJohn Kugelman-0/+2
2021-10-01path.push() should work as expected on windows verbatim pathsSean Young-7/+46
2021-09-25Apply 16 commits (squashed)Frank Steffahn-1/+1
---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::fmt ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::{rc, sync} ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::string ---------- Fix spacing for links inside code blocks in alloc::vec ---------- Fix spacing for links inside code blocks in core::option ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in core::result ---------- Fix spacing for links inside code blocks in core::{iter::{self, iterator}, stream::stream, poll} ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{fs, path} ---------- Fix spacing for links inside code blocks in std::{collections, time} ---------- Fix spacing for links inside code blocks in and make formatting of `&str`-like types consistent in std::ffi::{c_str, os_str} ---------- Fix spacing for links inside code blocks, and improve link tooltips in std::ffi ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{io::{self, buffered::{bufreader, bufwriter}, cursor, util}, net::{self, addr}} ---------- Fix typo in link to `into` for `OsString` docs ---------- Remove tooltips that will probably become redundant in the future ---------- Apply suggestions from code review Replacing `…std/primitive.reference.html` paths with just `reference` Co-authored-by: Joshua Nelson <github@jyn.dev> ---------- Also replace `…std/primitive.reference.html` paths with just `reference` in `core::pin`
2021-08-22Auto merge of #85166 - mbhall88:file-prefix, r=dtolnaybors-3/+62
add file_prefix method to std::path This is an initial implementation of `std::path::Path::file_prefix`. It is effectively a "left" variant of the existing [`file_stem`](https://doc.rust-lang.org/std/path/struct.Path.html#method.file_stem) method. An illustration of the difference is ```rust use std::path::Path; let path = Path::new("foo.tar.gz"); assert_eq!(path.file_stem(), Some("foo.tar")); assert_eq!(path.file_prefix(), Some("foo")); ``` In my own development, I generally find I almost always want the prefix, rather than the stem, so I thought it might be best to suggest it's addition to libstd. Of course, as this is my first contribution, I expect there is probably more work that needs to be done. Additionally, if the libstd team feel this isn't appropriate then so be it. There has been some [discussion about this on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/file_lstem/near/238076313) and a user there suggested I open a PR to see whether someone in the libstd team thinks it is worth pursuing.
2021-08-20Auto merge of #86898 - the8472:path-cmp, r=dtolnaybors-7/+40
Add fast path for Path::cmp that skips over long shared prefixes ``` # before test path::tests::bench_path_cmp_fast_path_buf_sort ... bench: 60,811 ns/iter (+/- 865) test path::tests::bench_path_cmp_fast_path_long ... bench: 6,459 ns/iter (+/- 275) test path::tests::bench_path_cmp_fast_path_short ... bench: 1,777 ns/iter (+/- 34) # after test path::tests::bench_path_cmp_fast_path_buf_sort ... bench: 38,140 ns/iter (+/- 211) test path::tests::bench_path_cmp_fast_path_long ... bench: 1,471 ns/iter (+/- 24) test path::tests::bench_path_cmp_fast_path_short ... bench: 1,106 ns/iter (+/- 9) ```
2021-08-17remove unnecessary empty checkMichael Hall-3/+1
2021-08-08Bump shrink_to stabilization to Rust 1.56David Tolnay-1/+1
2021-07-06optimize {Path,PathBuf,Components}::{cmp,partial_cmp} for shared prefixesThe8472-6/+39
2021-07-06Stabilize Vec<T>::shrink_toYoh Deadfall-1/+1
2021-07-06use Eq::eq instead of Iterator::eq implementationThe8472-1/+1
2021-06-24make docs clearer about how hidden files are dealt withMichael Hall-5/+19
2021-06-24change return signature for split_file_at_dotMichael Hall-6/+8
2021-06-18Auto merge of #85747 - maxwase:path-symlinks-methods, r=m-ou-sebors-0/+26
Path methods — symlinks improvement This PR adds symlink method for the `Path`. Tracking issue: #85748 For the discussion you can see [internals topic](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776) P.S. I'm not fully sure about `stable` attribute, correct me if I'm wrong.
2021-06-18`no_run` and `ignore` doc attributesMax Wase-1/+2
2021-06-15simplify logic for split_file_at_dotMichael Hall-8/+4
2021-06-09optimize Eq implementation for pathsThe8472-1/+1
Filesystems generally have a tree-ish structure which means paths are more likely to share a prefix than a suffix. Absolute paths are especially prone to share long prefixes.
2021-06-06Update doc library/std/src/path.rsMax Wase-1/+0
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-06-05Rollup merge of #85760 - ChrisDenton:path-doc-platform-specific, r=m-ou-seGuillaume Gomez-9/+9
Possible errors when accessing file metadata are platform specific In particular the `is_dir`, `is_file` and `exists` functions suggests that querying a file requires querying the directory. On Windows this is not normally true. r? `@m-ou-se`
2021-05-27Possible errors when reading file metadata are platform specificChris Denton-9/+9
In particular the `is_dir`, `is_file` and `exists` functions says that querying a file requires querying the directory. On Windows this is not normally true.
2021-05-27Review fixes + doc-featuresMax Wase-4/+5
2021-05-27Document `From` impls in path.rsDeadbeef-0/+24
2021-05-27Tracking issue add.Max Wase-1/+1
2021-05-27Fix `is_symlink()` method for `Path` using added `is_symlink()` method for ↵Max Wase-3/+2
`Metadata`
2021-05-27Add `is_symlink()` method for `Path`.Max Wase-0/+26
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-5/+1
can specialize it Windows implementation of `fs::try_exists`
2021-05-11Fix typo in commentAndrew Halle-1/+1
missing space in "rootseparator"
2021-05-11add file_prefix methodMichael Hall-2/+51
2021-04-27Override `clone_from` method for PathBuf and OsStringBenoît du Garreau-1/+13
2021-03-31Apply suggestions from code reviewFrank Steffahn-2/+2
More links, one more occurrence of “a OsString” Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2021-03-31Add a few missing links, fix a typoFrank Steffahn-7/+7
2021-03-16Rollup merge of #81822 - Kixunil:path_try_exists, r=kennytmYuki Okushi-0/+30
Added `try_exists()` method to `std::path::Path` This method is similar to the existing `exists()` method, except it doesn't silently ignore the errors, leading to less error-prone code. This change intentionally does NOT touch the documentation of `exists()` nor recommend people to use this method while it's unstable. Such changes are reserved for stabilization to prevent confusing people. Apart from that it avoids conflicts with #80979. `@joshtriplett` requested this PR in [internals discussion](https://internals.rust-lang.org/t/the-api-of-path-exists-encourages-broken-code/13817/25?u=kixunil)
2021-03-16Filled tracking issue for path_try_existsMartin Habovstiak-1/+1
This adds the ID of the tracking issue to the feature.
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+2
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-16Add caveat to Path::display() about lossinessManish Goregaokar-2/+6
2021-02-16a few more diagnostic itemsAndrea Nall-0/+1
2021-02-15requested/proposed changesAndrea Nall-1/+1
2021-02-15add diagnostic itemsAndrea Nall-0/+1
Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-06Added `try_exists()` method to `std::path::Path`Martin Habovstiak-0/+30
This method is similar to the existing `exists()` method, except it doesn't silently ignore the errors, leading to less error-prone code. This change intentionally does NOT touch the documentation of `exists()` nor recommend people to use this method while it's unstable. Such changes are reserved for stabilization to prevent confusing people. Apart from that it avoids conflicts with #80979.
2021-01-22Inline methods of Path and OsStringBenoît du Garreau-0/+69
2020-12-31Remove many unnecessary manual link resolves from libraryCamelid-1/+0
Now that #76934 has merged, we can remove a lot of these! E.g, this is no longer necessary: [`Vec<T>`]: Vec
2020-10-27Clean up intra-doc links in `std::path`Camelid-6/+5
2020-10-12Use intra-doc links for links to module-level docsCamelid-2/+2
2020-09-30Fix is_absolute on WASIIngvar Stepanyan-1/+1
WASI does not match `cfg(unix)`, but its paths are Unix-like (`/some/path`) and don't have Windows-like prefixes. Without this change, `is_absolute` for paths like `/some/path` was returning `false`on a WASI target, which is obviously not true and undesirable.
2020-09-19Rollup merge of #73963 - hellow554:unsafe_path, r=Mark-SimulacrumRalf Jung-19/+18
deny(unsafe_op_in_unsafe_fn) in libstd/path.rs The libstd/path.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-1400/+3
Also doing fmt inplace as requested.
2020-08-15Auto merge of #75246 - pickfire:patch-5, r=Amanieubors-2/+7
Add more examples to Path ends_with We faced a footgun when using ends_with to check extension, showing an example could prevent that. https://github.com/rust-dc/fish-manpage-completions/pull/106/commits/2c155e50b2d9e607174908b3f80f1dcf92693eee
2020-08-15Use resolve.conf as example for Path ends_withIvan Tham-6/+6
2020-08-11deny(unsafe_op_in_unsafe_fn) in libstd/path.rsMarcel Hellwig-20/+19