-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Added Default impl to PathBuf #38764
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. |
👍 |
@rfcbot fcp merge |
Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I feel like we've discussed this before and decided not to have a default for paths because it's not clear what it means to be a 'default' path. This implementation I think creates an empty path, but semantically that does not strike me as a 'default path', it strikes me more like a null path and a source of errors. |
@rfcbot concern there's no obvious default for paths per above |
@brson Yes, I believe this came up for |
A generally good rule of thumb is that if a type has a no-arg |
@brson ping? |
Also note that this has precedent in Iterator::unzip which requires Default. |
And you would use default for that, not new? |
I don't quite follow how that is precedent for Path::default. |
I'm afraid I still don't see any obvious motivation here except for @sfackler's rule of thumb that types that implement |
@brson: the Empty strings might not be a reasonable default for a lot of containers too, but that's the way stdlib seems to point. |
I feel like this is a pretty good point. Paths have additional semantics in the environment that strings don't have. I don't feel strongly either way on this given @brson's concerns. It does feel like a possible footgun, but I think adding a |
I agree with @brson that there's a potential footgun here, but I think it's relatively minor, and OTOH not being able to work easily with things like |
@brson I'm not really sure if I see the footgun. What errors could arise from the PathBuf that wouldn't already have to be handled by the user? |
See also #32990. The empty path makes sense for both |
Ping @brson, are you satisfied by the recent arguments? |
@aturon No, but I clicked the box anyway. |
Thanks all, and thanks @Aaronepower for sticking in there! @bors: r+ rollup |
📌 Commit 108293d has been approved by |
Added Default impl to PathBuf
Added Default impl to PathBuf
Added Default impl to PathBuf
Added Default impl to PathBuf
No description provided.