-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr #83581
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Seems reasonable to me, and the feature gate you used seems fine. This shouldn't be insta-stable, though; it should be marked as unstable for a while, and stabilized once we have some experience with it. Some logistical complications: these traits aren't currently sealed, which means theoretically, someone could have implemented them for a type outside the standard library. We'll need to see if anyone has done so. The easiest way to do that would be to first make a PR to seal these traits, and run that through crater. If that doesn't turn up any failures, then we can merge it, and subsequently add methods to these traits. |
As it turns out, m-ou-se recently did a crater run of sealing a number of traits, including I can seal the trait and submit the PR for another run if you like, but I wouldn't expect significant changes since January. Should I assume that, since breaking existing, working code is frowned upon, this is a bit of a non-starter? |
Sealing that one is probably a non-starter, then, but we could make a new sealed extension trait. |
Sorry for the delay — life stuff. If that's an allowable solution to this problem, I can certainly do that. I'm not yet intuitively good at Rust–style naming. What would be a good name for the new, sealed trait? It's like |
I'd probably just go with |
If that's aesthetically acceptable, I can make that change and update the PR today. |
☔ The latest upstream changes (presumably #84200) made this pull request unmergeable. Please resolve the merge conflicts. |
@arennow Can you open a tracking issue and replace the We can discuss things like the name of the trait after this is merged (and before it is stabilized) on that tracking issue. |
@arennow Ping from triage, would you mind follow the instructions above? Thanks! |
Yes, sorry. Life again. I should be able to get that done this weekend. I just want to make sure I do things slowly to make sure I do them correctly. Trying to be a good open source citizen |
DirEntryExt2 is a new trait with the same purpose as DirEntryExt, but sealed
Update: That was less intimidating than I expected it to be. There are several things I'm not sure I did completely right, but I'd be more than happy to correct… whatever they may be. I'm pretty new to contributing to open source projects, and this is a big one. |
r? @m-ou-se |
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
@bors r+ |
📌 Commit 469f467 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#83581 (Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr) - rust-lang#85377 (aborts: Clarify documentation and comments) - rust-lang#86685 (double-check mutability inside Allocation) - rust-lang#86794 (Stabilize `Seek::rewind()`) - rust-lang#86852 (Remove some doc aliases) - rust-lang#86878 (:arrow_up: rust-analyzer) - rust-lang#86886 (Remove `impl Clean for {Ident, Symbol}`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Greetings!
This is my first PR here, so please forgive me if I've missed an important step or otherwise done something wrong. I'm very open to suggestions/fixes/corrections.
This PR adds a function that allows
std::fs::DirEntry
to vend a borrow of its filename on Unix platforms, which is especially useful for sorting. (Windows has (as I understand it) encoding differences that require an allocation.) This new function sits alongside the cross-platformfile_name(&self) -> OsString
function.I pitched this idea in an internals thread, and no one objected vehemently, so here we are.
I understand features in general, I believe, but I'm not at all confident that my whole-cloth invention of a new feature string (as required by the compiler) was correct (or that the name is appropriate). Further, there doesn't appear to be a test for the sibling
ino
function, so I didn't add one for this similarly trivial function either. If it's desirable that I should do so, I'd be happy to [figure out how to] do that.The following is a trivial sample of a use-case for this function, in which directory entries are sorted without any additional allocations: