@@ -2215,12 +2215,22 @@ impl Path {
2215
2215
/// This function will traverse symbolic links to query information about the
2216
2216
/// destination file. In case of broken symbolic links this will return `false`.
2217
2217
///
2218
+ /// If you cannot access the directory containing the file, e.g. because of a
2219
+ /// permission error, this will return `false`.
2220
+ ///
2218
2221
/// # Examples
2219
2222
///
2220
2223
/// ```no_run
2221
2224
/// use std::path::Path;
2222
2225
/// assert_eq!(Path::new("does_not_exist.txt").exists(), false);
2223
2226
/// ```
2227
+ ///
2228
+ /// # See Also
2229
+ ///
2230
+ /// This is a convenience function that coerces errors to false. If you want to
2231
+ /// check errors, call [fs::metadata].
2232
+ ///
2233
+ /// [fs::metadata]: ../../std/fs/fn.metadata.html
2224
2234
#[ stable( feature = "path_ext" , since = "1.5.0" ) ]
2225
2235
pub fn exists ( & self ) -> bool {
2226
2236
fs:: metadata ( self ) . is_ok ( )
@@ -2231,13 +2241,25 @@ impl Path {
2231
2241
/// This function will traverse symbolic links to query information about the
2232
2242
/// destination file. In case of broken symbolic links this will return `false`.
2233
2243
///
2244
+ /// If you cannot access the directory containing the file, e.g. because of a
2245
+ /// permission error, this will return `false`.
2246
+ ///
2234
2247
/// # Examples
2235
2248
///
2236
2249
/// ```no_run
2237
2250
/// use std::path::Path;
2238
2251
/// assert_eq!(Path::new("./is_a_directory/").is_file(), false);
2239
2252
/// assert_eq!(Path::new("a_file.txt").is_file(), true);
2240
2253
/// ```
2254
+ ///
2255
+ /// # See Also
2256
+ ///
2257
+ /// This is a convenience function that coerces errors to false. If you want to
2258
+ /// check errors, call [fs::metadata] and handle its Result. Then call
2259
+ /// [fs::Metadata::is_file] if it was Ok.
2260
+ ///
2261
+ /// [fs::metadata]: ../../std/fs/fn.metadata.html
2262
+ /// [fs::Metadata::is_file]: ../../std/fs/struct.Metadata.html#method.is_file
2241
2263
#[ stable( feature = "path_ext" , since = "1.5.0" ) ]
2242
2264
pub fn is_file ( & self ) -> bool {
2243
2265
fs:: metadata ( self ) . map ( |m| m. is_file ( ) ) . unwrap_or ( false )
@@ -2248,13 +2270,25 @@ impl Path {
2248
2270
/// This function will traverse symbolic links to query information about the
2249
2271
/// destination file. In case of broken symbolic links this will return `false`.
2250
2272
///
2273
+ /// If you cannot access the directory containing the file, e.g. because of a
2274
+ /// permission error, this will return `false`.
2275
+ ///
2251
2276
/// # Examples
2252
2277
///
2253
2278
/// ```no_run
2254
2279
/// use std::path::Path;
2255
2280
/// assert_eq!(Path::new("./is_a_directory/").is_dir(), true);
2256
2281
/// assert_eq!(Path::new("a_file.txt").is_dir(), false);
2257
2282
/// ```
2283
+ ///
2284
+ /// # See Also
2285
+ ///
2286
+ /// This is a convenience function that coerces errors to false. If you want to
2287
+ /// check errors, call [fs::metadata] and handle its Result. Then call
2288
+ /// [fs::Metadata::is_dir] if it was Ok.
2289
+ ///
2290
+ /// [fs::metadata]: ../../std/fs/fn.metadata.html
2291
+ /// [fs::Metadata::is_dir]: ../../std/fs/struct.Metadata.html#method.is_dir
2258
2292
#[ stable( feature = "path_ext" , since = "1.5.0" ) ]
2259
2293
pub fn is_dir ( & self ) -> bool {
2260
2294
fs:: metadata ( self ) . map ( |m| m. is_dir ( ) ) . unwrap_or ( false )
0 commit comments