File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -2506,12 +2506,17 @@ impl Path {
2506
2506
/// check errors, call [`fs::metadata`] and handle its Result. Then call
2507
2507
/// [`fs::Metadata::is_file`] if it was Ok.
2508
2508
///
2509
- /// Note that the explanation about using `open` instead of `is_file`
2510
- /// that is present in the [`fs::Metadata`] documentation also applies here.
2509
+ /// When the goal is simply to read from (or write to) the source, the most
2510
+ /// reliable way to test the source can be read (or written to) is to open
2511
+ /// it. Only using `is_file` can break workflows like `diff <( prog_a )` on
2512
+ /// a Unix-like system for example. See [`File::open`] or
2513
+ /// [`OpenOptions::open`] for more information.
2511
2514
///
2512
2515
/// [`fs::metadata`]: ../../std/fs/fn.metadata.html
2513
2516
/// [`fs::Metadata`]: ../../std/fs/struct.Metadata.html
2514
2517
/// [`fs::Metadata::is_file`]: ../../std/fs/struct.Metadata.html#method.is_file
2518
+ /// [`File::open`]: ../../std/fs/struct.File.html#method.open
2519
+ /// [`OpenOptions::open`]: ../../std/fs/struct.OpenOptions.html#method.open
2515
2520
#[ stable( feature = "path_ext" , since = "1.5.0" ) ]
2516
2521
pub fn is_file ( & self ) -> bool {
2517
2522
fs:: metadata ( self ) . map ( |m| m. is_file ( ) ) . unwrap_or ( false )
You can’t perform that action at this time.
0 commit comments