From c291d2adecbf13685ed321d7699ba7bb0b60806a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Tue, 20 Sep 2022 11:12:03 -0500 Subject: [PATCH] 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. --- library/std/src/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 5dfeb517a199..4f9dff1ef035 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -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: ///