Skip to content

Commit

Permalink
Rollup merge of rust-lang#102058 - mqudsi:path_extension_docs, r=thomcc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matthiaskrgr authored Sep 21, 2022
2 parents fd164c0 + c291d2a commit 556c4e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ impl Path {
self.file_name().map(split_file_at_dot).and_then(|(before, _after)| Some(before))
}

/// Extracts the extension of [`self.file_name`], if possible.
/// Extracts the extension (without the leading dot) of [`self.file_name`], if possible.
///
/// The extension is:
///
Expand Down

0 comments on commit 556c4e0

Please sign in to comment.