Skip to content

Commit d25d6c5

Browse files
committed
Update the documentation to point to open instead of is_file and is_dir
1 parent c1243db commit d25d6c5

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/libstd/fs.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -1033,14 +1033,16 @@ impl Metadata {
10331033
/// [`is_dir`], and will be false for symlink metadata
10341034
/// obtained from [`symlink_metadata`].
10351035
///
1036-
/// This property means it is often more useful to use `!file_type.is_dir()`
1037-
/// than `file_type.is_file()` when your goal is to read bytes from a
1038-
/// source: the former includes symlink and pipes when the latter does not,
1039-
/// meaning you will break workflows like `diff <( prog_a ) <( prog_b )` on
1040-
/// a Unix-like system for example.
1036+
/// When the goal is simply to read from (or write to) the source, the most
1037+
/// reliable way to test the source can be read (or written to) is to open
1038+
/// it. Only using `is_file` can break workflows like `diff <( prog_a )` on
1039+
/// a Unix-like system for example. See [`File::open`] or
1040+
/// [`OpenOptions::open`] for more information.
10411041
///
10421042
/// [`is_dir`]: struct.Metadata.html#method.is_dir
10431043
/// [`symlink_metadata`]: fn.symlink_metadata.html
1044+
/// [`File::open`]: struct.File.html#method.open
1045+
/// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
10441046
///
10451047
/// # Examples
10461048
///
@@ -1313,14 +1315,16 @@ impl FileType {
13131315
/// [`is_dir`] and [`is_symlink`]; only zero or one of these
13141316
/// tests may pass.
13151317
///
1316-
/// This property means it is often more useful to use `!file_type.is_dir()`
1317-
/// than `file_type.is_file()` when your goal is to read bytes from a
1318-
/// source: the former includes symlink and pipes when the latter does not,
1319-
/// meaning you will break workflows like `diff <( prog_a ) <( prog_b )` on
1320-
/// a Unix-like system for example.
1318+
/// When the goal is simply to read from (or write to) the source, the most
1319+
/// reliable way to test the source can be read (or written to) is to open
1320+
/// it. Only using `is_file` can break workflows like `diff <( prog_a )` on
1321+
/// a Unix-like system for example. See [`File::open`] or
1322+
/// [`OpenOptions::open`] for more information.
13211323
///
13221324
/// [`is_dir`]: struct.FileType.html#method.is_dir
13231325
/// [`is_symlink`]: struct.FileType.html#method.is_symlink
1326+
/// [`File::open`]: struct.File.html#method.open
1327+
/// [`OpenOptions::open`]: struct.OpenOptions.html#method.open
13241328
///
13251329
/// # Examples
13261330
///

src/libstd/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ impl Path {
25062506
/// check errors, call [`fs::metadata`] and handle its Result. Then call
25072507
/// [`fs::Metadata::is_file`] if it was Ok.
25082508
///
2509-
/// Note that the explanation about using `!is_dir` instead of `is_file`
2509+
/// Note that the explanation about using `open` instead of `is_file`
25102510
/// that is present in the [`fs::Metadata`] documentation also applies here.
25112511
///
25122512
/// [`fs::metadata`]: ../../std/fs/fn.metadata.html

0 commit comments

Comments
 (0)