@@ -2175,22 +2175,29 @@ impl Path {
21752175 /// assert_eq!("foo", Path::new("foo.rs").file_stem().unwrap());
21762176 /// assert_eq!("foo.tar", Path::new("foo.tar.gz").file_stem().unwrap());
21772177 /// ```
2178+ ///
2179+ /// # See Also
2180+ /// This method is similar to [`Path::file_prefix`], which extracts the portion of the file name
2181+ /// before the *first* `.`
2182+ ///
2183+ /// [`Path::file_prefix`]: Path::file_prefix
2184+ ///
21782185 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
21792186 pub fn file_stem ( & self ) -> Option < & OsStr > {
21802187 self . file_name ( ) . map ( rsplit_file_at_dot) . and_then ( |( before, after) | before. or ( after) )
21812188 }
21822189
2183- /// Extracts the prefix (non-extension(s)) portion of [`self.file_name`]. This is a "left"
2184- /// variant of `file_stem` - meaning it takes the portion of the file name before the *first* `.`
2185- ///
2186- /// [`self.file_name`]: Path::file_name
2190+ /// Extracts the prefix of [`self.file_name`].
21872191 ///
21882192 /// The prefix is:
21892193 ///
21902194 /// * [`None`], if there is no file name;
21912195 /// * The entire file name if there is no embedded `.`;
2196+ /// * The portion of the file name before the first non-beginning `.`;
21922197 /// * The entire file name if the file name begins with `.` and has no other `.`s within;
2193- /// * Otherwise, the portion of the file name before the first `.`
2198+ /// * The portion of the file name before the second `.` if the file name begins with `.`
2199+ ///
2200+ /// [`self.file_name`]: Path::file_name
21942201 ///
21952202 /// # Examples
21962203 ///
@@ -2201,6 +2208,13 @@ impl Path {
22012208 /// assert_eq!("foo", Path::new("foo.rs").file_prefix().unwrap());
22022209 /// assert_eq!("foo", Path::new("foo.tar.gz").file_prefix().unwrap());
22032210 /// ```
2211+ ///
2212+ /// # See Also
2213+ /// This method is similar to [`Path::file_stem`], which extracts the portion of the file name
2214+ /// before the *last* `.`
2215+ ///
2216+ /// [`Path::file_stem`]: Path::file_stem
2217+ ///
22042218 #[ unstable( feature = "path_file_prefix" , issue = "86319" ) ]
22052219 pub fn file_prefix ( & self ) -> Option < & OsStr > {
22062220 self . file_name ( )
0 commit comments