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.
This commit is contained in:
parent
74c42ac173
commit
ea70a88710
1 changed files with 6 additions and 1 deletions
|
@ -975,13 +975,18 @@ impl FileType {
|
|||
|
||||
/// Test whether this file type represents a symbolic link.
|
||||
///
|
||||
/// The Metadata struct needs to be retreived with
|
||||
/// fs::symlink_metadata() not fs::metadata(). metadata()
|
||||
/// always follows symbolic links, so is_symlink will
|
||||
/// always return false for the underlying file.
|
||||
///
|
||||
/// # 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue