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