-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Clarify Path::extension() semantics in docs abstract #102058
Conversation
State up-front and center what shape the returned extension will have, without making the user read through the description and examples. Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @thomcc (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup |
Thanks, @thomcc. |
But there are other important questions. E.g. is |
I'd approve additional clarifications like that, but I don't think they block this one. |
@the8472 pedantically, whether or not an "extension" is ".ext" or "ext" affects each and every file and each and every extension while "tar.gz" or "gz" affects only cases where you are matching against a compound extension or a file with potentially a compound extension. Developers that get the first one wrong will get the wrong answer every single time, while developers not taking into account the relatively fringe case of compound extensions will have broken code some fraction of the time. Less pedantically and on a more personal/subjective level, as best as I can recollect, every api I've worked with treated the extension of "foo.tar.gz" to be ".gz" (or "gz" as the case may be) so it's not a question that I personally found as pressing to answer (it's also IMHO the only logical result because any file may have a dot/period in the non-ext part of its name/path). |
People have at least asked for such methods, e.g. in #86319 so if they existed then we'd have to disambiguate the difference which I think would be more important than mentioning whether the dot is included or not. |
Clarify Path::extension() semantics in docs abstract State up-front and center what shape the returned extension will have, without making the user read through the description and examples. This is a doc-only change. There are no changes to the API contract and the clarification is in line with what was already stated/promised in the existing doc text - just clarified, summarized, and served bright and early. Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it. `@rustbot` label +A-docs
Clarify Path::extension() semantics in docs abstract State up-front and center what shape the returned extension will have, without making the user read through the description and examples. This is a doc-only change. There are no changes to the API contract and the clarification is in line with what was already stated/promised in the existing doc text - just clarified, summarized, and served bright and early. Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it. ``@rustbot`` label +A-docs
Rollup of 7 pull requests Successful merges: - rust-lang#89891 (`alloc`: add unstable cfg features `no_rc` and `no_sync`) - rust-lang#101995 (Add another example for `uN::carrying_mul`) - rust-lang#102031 (Adding ignore fuchsia tests for Backtrace, ErrorKind cases) - rust-lang#102041 (Improve `-Zmeta-stats` some more) - rust-lang#102045 (fix ConstProp handling of written_only_inside_own_block_locals) - rust-lang#102058 (Clarify Path::extension() semantics in docs abstract) - rust-lang#102059 (Use rebind instead of dummy binder in `SameTypeModuloInfer` relation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
State up-front and center what shape the returned extension will have, without making the user read through the description and examples.
This is a doc-only change. There are no changes to the API contract and the clarification is in line with what was already stated/promised in the existing doc text - just clarified, summarized, and served bright and early.
Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it.
@rustbot label +A-docs