diff options
| author | bors <bors@rust-lang.org> | 2017-01-22 01:19:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-22 01:19:18 +0000 |
| commit | 1b063750343601167f3d061a913172db2a0c2708 (patch) | |
| tree | 91dad2a25ef62fa98dcf25fe67d61f0d9360582f /src/libstd | |
| parent | 9761b17d558d0c980d4d2d5a0baba54f2bc6b63a (diff) | |
| parent | f55bbaa63467eb8196ac9476e095ec069563846e (diff) | |
| download | rust-1b063750343601167f3d061a913172db2a0c2708.tar.gz rust-1b063750343601167f3d061a913172db2a0c2708.zip | |
Auto merge of #39176 - CartesianDaemon:master, r=frewsxcv
Use fs::symlink_metadata in doc for is_symlink fs::metadata() follows symlinks so is_symlink() will always return false. Use symlink_metadata instead in the example in the documentation. See issue #39088.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/fs.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 9cff787ced3..d4ac162a594 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -978,13 +978,24 @@ impl FileType { /// Test whether this file type represents a symbolic link. /// + /// The underlying [`Metadata`] struct needs to be retrieved + /// with the [`fs::symlink_metadata`] function and not the + /// [`fs::metadata`] function. The [`fs::metadata`] function + /// follows symbolic links, so [`is_symlink`] would always + /// return false for the target file. + /// + /// [`Metadata`]: struct.Metadata.html + /// [`fs::metadata`]: fn.metadata.html + /// [`fs::symlink_metadata`]: fn.symlink_metadata.html + /// [`is_symlink`]: struct.FileType.html#method.is_symlink + /// /// # Examples /// /// ``` /// # fn foo() -> std::io::Result<()> { /// use std::fs; /// - /// let metadata = try!(fs::metadata("foo.txt")); + /// let metadata = try!(fs::symlink_metadata("foo.txt")); /// let file_type = metadata.file_type(); /// /// assert_eq!(file_type.is_symlink(), false); |
