Skip to content
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

Fix Issue #48345, is_file, is_dir, and is_symlink note mutual exclusion #49076

Merged
merged 1 commit into from
Mar 24, 2018
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
35 changes: 32 additions & 3 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,13 @@ impl Metadata {
FileType(self.0.file_type())
}

/// Returns whether this metadata is for a directory.
/// Returns whether this metadata is for a directory. The
/// result is mutually exclusive to the result of
/// [`is_file`], and will be false for symlink metadata
/// obtained from [`symlink_metadata`].
///
/// [`is_file`]: struct.Metadata.html#method.is_file
/// [`symlink_metadata`]: fn.symlink_metadata.html
///
/// # Examples
///
Expand All @@ -923,7 +929,13 @@ impl Metadata {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_dir(&self) -> bool { self.file_type().is_dir() }

/// Returns whether this metadata is for a regular file.
/// Returns whether this metadata is for a regular file. The
/// result is mutually exclusive to the result of
/// [`is_dir`], and will be false for symlink metadata
/// obtained from [`symlink_metadata`].
///
/// [`is_dir`]: struct.Metadata.html#method.is_dir
/// [`symlink_metadata`]: fn.symlink_metadata.html
///
/// # Examples
///
Expand Down Expand Up @@ -1148,7 +1160,13 @@ impl Permissions {
}

impl FileType {
/// Test whether this file type represents a directory.
/// Test whether this file type represents a directory. The
/// result is mutually exclusive to the results of
/// [`is_file`] and [`is_symlink`]; only zero or one of these
/// tests may pass.
///
/// [`is_file`]: struct.FileType.html#method.is_file
/// [`is_symlink`]: struct.FileType.html#method.is_symlink
///
/// # Examples
///
Expand All @@ -1167,6 +1185,12 @@ impl FileType {
pub fn is_dir(&self) -> bool { self.0.is_dir() }

/// Test whether this file type represents a regular file.
/// The result is mutually exclusive to the results of
/// [`is_dir`] and [`is_symlink`]; only zero or one of these
/// tests may pass.
///
/// [`is_dir`]: struct.FileType.html#method.is_dir
/// [`is_symlink`]: struct.FileType.html#method.is_symlink
///
/// # Examples
///
Expand All @@ -1185,6 +1209,9 @@ impl FileType {
pub fn is_file(&self) -> bool { self.0.is_file() }

/// Test whether this file type represents a symbolic link.
/// The result is mutually exclusive to the results of
/// [`is_dir`] and [`is_file`]; only zero or one of these
/// tests may pass.
///
/// The underlying [`Metadata`] struct needs to be retrieved
/// with the [`fs::symlink_metadata`] function and not the
Expand All @@ -1195,6 +1222,8 @@ impl FileType {
/// [`Metadata`]: struct.Metadata.html
/// [`fs::metadata`]: fn.metadata.html
/// [`fs::symlink_metadata`]: fn.symlink_metadata.html
/// [`is_dir`]: struct.FileType.html#method.is_dir
/// [`is_file`]: struct.FileType.html#method.is_file
/// [`is_symlink`]: struct.FileType.html#method.is_symlink
///
/// # Examples
Expand Down