Skip to content

Commit 93cbad6

Browse files
committed
Add documentation to point to !is_dir instead of is_file
1 parent 50c0192 commit 93cbad6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libstd/fs.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,12 @@ impl FileType {
13071307
/// [`is_dir`] and [`is_symlink`]; only zero or one of these
13081308
/// tests may pass.
13091309
///
1310+
/// This property means it is often more useful to use `!file_type.is_dir()`
1311+
/// than `file_type.is_file()` when your goal is to read bytes from a
1312+
/// source: the former includes symlink and pipes when the latter does not,
1313+
/// meaning you will break workflows like `diff <( prog_a ) <( prog_b )` on
1314+
/// a Unix-like system for example.
1315+
///
13101316
/// [`is_dir`]: struct.FileType.html#method.is_dir
13111317
/// [`is_symlink`]: struct.FileType.html#method.is_symlink
13121318
///

0 commit comments

Comments
 (0)