Rollup merge of #89797 - jkugelman:must-use-is_condition-tests, r=joshtriplett
Add #[must_use] to is_condition tests I threw in `std::path::Path::has_root` for funsies. A continuation of #89718. Parent issue: #89692 r? ```@joshtriplett```
This commit is contained in:
commit
4cf0f1fede
6 changed files with 47 additions and 0 deletions
|
@ -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)
|
||||
|
@ -2016,6 +2018,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") {
|
||||
|
@ -2040,6 +2043,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()
|
||||
|
@ -2066,6 +2070,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()
|
||||
|
@ -2705,6 +2710,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)
|
||||
}
|
||||
|
@ -2731,6 +2737,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)
|
||||
}
|
||||
|
@ -2757,6 +2764,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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue