提交 b75d1f0c 编写于 作者: B bors

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.
...@@ -2237,7 +2237,7 @@ pub fn exists(&self) -> bool { ...@@ -2237,7 +2237,7 @@ pub fn exists(&self) -> bool {
fs::metadata(self).is_ok() fs::metadata(self).is_ok()
} }
/// Returns whether the path is pointing at a regular file. /// Returns whether the path exists on disk and is pointing at a regular file.
/// ///
/// This function will traverse symbolic links to query information about the /// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`. /// destination file. In case of broken symbolic links this will return `false`.
...@@ -2266,7 +2266,7 @@ pub fn is_file(&self) -> bool { ...@@ -2266,7 +2266,7 @@ pub fn is_file(&self) -> bool {
fs::metadata(self).map(|m| m.is_file()).unwrap_or(false) fs::metadata(self).map(|m| m.is_file()).unwrap_or(false)
} }
/// Returns whether the path is pointing at a directory. /// Returns whether the path exists on disk and is pointing at a directory.
/// ///
/// This function will traverse symbolic links to query information about the /// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `false`. /// destination file. In case of broken symbolic links this will return `false`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册