Skip to content

Commit b75d1f0

Browse files
committed
Auto merge of #43614 - pornel:is_gotcha, r=BurntSushi
Emphasise that these functions look at the disk, not just the path I thought that `PathBuf::new("foo/bar/").is_dir()` is always true, because the path ends in `/`. However, this is not what `is_dir()` function does. So I've updated the docs to make it clear.
2 parents 4596c71 + 4792d28 commit b75d1f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/path.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ impl Path {
22372237
fs::metadata(self).is_ok()
22382238
}
22392239

2240-
/// Returns whether the path is pointing at a regular file.
2240+
/// Returns whether the path exists on disk and is pointing at a regular file.
22412241
///
22422242
/// This function will traverse symbolic links to query information about the
22432243
/// destination file. In case of broken symbolic links this will return `false`.
@@ -2266,7 +2266,7 @@ impl Path {
22662266
fs::metadata(self).map(|m| m.is_file()).unwrap_or(false)
22672267
}
22682268

2269-
/// Returns whether the path is pointing at a directory.
2269+
/// Returns whether the path exists on disk and is pointing at a directory.
22702270
///
22712271
/// This function will traverse symbolic links to query information about the
22722272
/// destination file. In case of broken symbolic links this will return `false`.

0 commit comments

Comments
 (0)