Skip to content

Commit

Permalink
Make a note about is_dir vs is_file in Path too
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Jun 11, 2020
1 parent ec63f9d commit c1243db
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2503,11 +2503,15 @@ impl Path {
/// # See Also
///
/// This is a convenience function that coerces errors to false. If you want to
/// check errors, call [fs::metadata] and handle its Result. Then call
/// [fs::Metadata::is_file] if it was Ok.
/// check errors, call [`fs::metadata`] and handle its Result. Then call
/// [`fs::Metadata::is_file`] if it was Ok.
///
/// [fs::metadata]: ../../std/fs/fn.metadata.html
/// [fs::Metadata::is_file]: ../../std/fs/struct.Metadata.html#method.is_file
/// Note that the explanation about using `!is_dir` instead of `is_file`
/// that is present in the [`fs::Metadata`] documentation also applies here.
///
/// [`fs::metadata`]: ../../std/fs/fn.metadata.html
/// [`fs::Metadata`]: ../../std/fs/struct.Metadata.html
/// [`fs::Metadata::is_file`]: ../../std/fs/struct.Metadata.html#method.is_file
#[stable(feature = "path_ext", since = "1.5.0")]
pub fn is_file(&self) -> bool {
fs::metadata(self).map(|m| m.is_file()).unwrap_or(false)
Expand Down

0 comments on commit c1243db

Please sign in to comment.