Skip to content

Commit c291d2a

Browse files
committed
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. 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.
1 parent 4136b59 commit c291d2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@ impl Path {
24012401
self.file_name().map(split_file_at_dot).and_then(|(before, _after)| Some(before))
24022402
}
24032403

2404-
/// Extracts the extension of [`self.file_name`], if possible.
2404+
/// Extracts the extension (without the leading dot) of [`self.file_name`], if possible.
24052405
///
24062406
/// The extension is:
24072407
///

0 commit comments

Comments
 (0)