@@ -2175,22 +2175,29 @@ impl Path {
2175
2175
/// assert_eq!("foo", Path::new("foo.rs").file_stem().unwrap());
2176
2176
/// assert_eq!("foo.tar", Path::new("foo.tar.gz").file_stem().unwrap());
2177
2177
/// ```
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
+ ///
2178
2185
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2179
2186
pub fn file_stem ( & self ) -> Option < & OsStr > {
2180
2187
self . file_name ( ) . map ( rsplit_file_at_dot) . and_then ( |( before, after) | before. or ( after) )
2181
2188
}
2182
2189
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`].
2187
2191
///
2188
2192
/// The prefix is:
2189
2193
///
2190
2194
/// * [`None`], if there is no file name;
2191
2195
/// * The entire file name if there is no embedded `.`;
2196
+ /// * The portion of the file name before the first non-beginning `.`;
2192
2197
/// * 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
2194
2201
///
2195
2202
/// # Examples
2196
2203
///
@@ -2201,6 +2208,13 @@ impl Path {
2201
2208
/// assert_eq!("foo", Path::new("foo.rs").file_prefix().unwrap());
2202
2209
/// assert_eq!("foo", Path::new("foo.tar.gz").file_prefix().unwrap());
2203
2210
/// ```
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
+ ///
2204
2218
#[ unstable( feature = "path_file_prefix" , issue = "86319" ) ]
2205
2219
pub fn file_prefix ( & self ) -> Option < & OsStr > {
2206
2220
self . file_name ( )
0 commit comments