Add #[must_use] to is_condition tests

A continuation of #89718.
This commit is contained in:
John Kugelman
2021-10-11 21:15:57 -04:00
parent 7cc8c44871
commit 01b439e764
6 changed files with 47 additions and 0 deletions

View File

@@ -215,6 +215,7 @@ impl<'a> Prefix<'a> {
/// assert!(!Disk(b'C').is_verbatim());
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_verbatim(&self) -> bool {
use self::Prefix::*;
@@ -247,6 +248,7 @@ impl<'a> Prefix<'a> {
/// assert!(path::is_separator('/')); // '/' works for both Unix and Windows
/// assert!(!path::is_separator('❤'));
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_separator(c: char) -> bool {
c.is_ascii() && is_sep_byte(c as u8)
@@ -2011,6 +2013,7 @@ impl Path {
///
/// [`has_root`]: Path::has_root
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
#[allow(deprecated)]
pub fn is_absolute(&self) -> bool {
if cfg!(target_os = "redox") {
@@ -2035,6 +2038,7 @@ impl Path {
///
/// [`is_absolute`]: Path::is_absolute
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
#[inline]
pub fn is_relative(&self) -> bool {
!self.is_absolute()
@@ -2061,6 +2065,7 @@ impl Path {
/// assert!(Path::new("/etc/passwd").has_root());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
#[inline]
pub fn has_root(&self) -> bool {
self.components().has_root()
@@ -2698,6 +2703,7 @@ impl Path {
/// a Unix-like system for example. See [`fs::File::open`] or
/// [`fs::OpenOptions::open`] for more information.
#[stable(feature = "path_ext", since = "1.5.0")]
#[must_use]
pub fn is_file(&self) -> bool {
fs::metadata(self).map(|m| m.is_file()).unwrap_or(false)
}
@@ -2724,6 +2730,7 @@ impl Path {
/// check errors, call [`fs::metadata`] and handle its [`Result`]. Then call
/// [`fs::Metadata::is_dir`] if it was [`Ok`].
#[stable(feature = "path_ext", since = "1.5.0")]
#[must_use]
pub fn is_dir(&self) -> bool {
fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false)
}
@@ -2750,6 +2757,7 @@ impl Path {
/// assert_eq!(link_path.exists(), false);
/// ```
#[unstable(feature = "is_symlink", issue = "85748")]
#[must_use]
pub fn is_symlink(&self) -> bool {
fs::symlink_metadata(self).map(|m| m.is_symlink()).unwrap_or(false)
}