-
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
Add notes and examples about non-intuitive PathBuf::set_extension
behavior
#104298
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon. Please see the contribution instructions for more information. |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
0d76ac7
to
500f4c6
Compare
library/std/src/path.rs
Outdated
/// Note that there are some exceptions when the parameter contains dots | ||
/// (then the new [`self.extension`] will only be the last part), or if the | ||
/// parameter is the empty string and the file stem also contains internal | ||
/// dots. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is a bit vague. How about something like this?
/// Note that there are some exceptions when the parameter contains dots | |
/// (then the new [`self.extension`] will only be the last part), or if the | |
/// parameter is the empty string and the file stem also contains internal | |
/// dots. | |
/// The new `extension` may contain dots and will be used in its entirety, | |
/// but only the part after the final dot will be reflected in [`self.extension()`][Self::extension]. | |
/// See the examples below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added. Also added the part about empty parameter and file stem with internal dots which was missing from your wording.
500f4c6
to
06acf69
Compare
…ehavior Basically, passing the empty string will actually remove the extension instead of setting it to the empty string. This might change what is considered to be an extension. Additionally, passing an extension that contains dots will make the path only consider the last part of it to be the new extension.
06acf69
to
40916ef
Compare
@rustbot label +S-waiting-on-review -S-waiting-on-author |
@bors r+ |
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#95985 (Add PhantomData marker to Context to make Context !Send and !Sync) - rust-lang#104298 (Add notes and examples about non-intuitive `PathBuf::set_extension` behavior) - rust-lang#105558 (Reduce HIR debug output) - rust-lang#106315 (Cleanup `mingw-tidy` docker job) - rust-lang#106354 (Rustdoc-Json: Report discriminant on all kinds of enum variant.) - rust-lang#106366 (Fix rustdoc ICE on bad typedef with mismatching types) - rust-lang#106376 (Update books) - rust-lang#106383 (Document some of the AST nodes) Failed merges: - rust-lang#106356 (clean: Remove `ctor_kind` from `VariantStruct`.) r? `@ghost` `@rustbot` modify labels: rollup
Basically, passing the empty string will actually remove the extension instead of setting it to the empty string. This might change what is considered to be an extension. Additionally, passing an extension that contains dots will make the path only consider the last part of it to be the new extension.