1
Fork 0

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:
Jack Vickeridge 2017-01-19 09:04:51 +00:00
parent 74c42ac173
commit ea70a88710

View file

@ -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);