Skip to content

Use fs::symlink_metadata in doc for is_symlink #39176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,13 +975,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);
Expand Down