mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
parent
7cc8c44871
commit
01b439e764
@ -1005,6 +1005,7 @@ impl Metadata {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_dir(&self) -> bool {
|
||||
self.file_type().is_dir()
|
||||
@ -1033,6 +1034,7 @@ impl Metadata {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_file(&self) -> bool {
|
||||
self.file_type().is_file()
|
||||
@ -1059,6 +1061,7 @@ impl Metadata {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[unstable(feature = "is_symlink", issue = "85748")]
|
||||
pub fn is_symlink(&self) -> bool {
|
||||
self.file_type().is_symlink()
|
||||
@ -1306,6 +1309,7 @@ impl FileType {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "file_type", since = "1.1.0")]
|
||||
pub fn is_dir(&self) -> bool {
|
||||
self.0.is_dir()
|
||||
@ -1338,6 +1342,7 @@ impl FileType {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "file_type", since = "1.1.0")]
|
||||
pub fn is_file(&self) -> bool {
|
||||
self.0.is_file()
|
||||
@ -1373,6 +1378,7 @@ impl FileType {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "file_type", since = "1.1.0")]
|
||||
pub fn is_symlink(&self) -> bool {
|
||||
self.0.is_symlink()
|
||||
|
@ -232,6 +232,7 @@ impl SocketAddr {
|
||||
/// assert_eq!(socket.is_ipv4(), true);
|
||||
/// assert_eq!(socket.is_ipv6(), false);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
|
||||
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
|
||||
pub const fn is_ipv4(&self) -> bool {
|
||||
@ -253,6 +254,7 @@ impl SocketAddr {
|
||||
/// assert_eq!(socket.is_ipv4(), false);
|
||||
/// assert_eq!(socket.is_ipv6(), true);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "sockaddr_checker", since = "1.16.0")]
|
||||
#[rustc_const_unstable(feature = "const_socketaddr", issue = "82485")]
|
||||
pub const fn is_ipv6(&self) -> bool {
|
||||
|
@ -233,6 +233,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ip", since = "1.50.0")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unspecified(&self) -> bool {
|
||||
match self {
|
||||
@ -256,6 +257,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ip", since = "1.50.0")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_loopback(&self) -> bool {
|
||||
match self {
|
||||
@ -281,6 +283,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_global(&self) -> bool {
|
||||
match self {
|
||||
@ -304,6 +307,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ip", since = "1.50.0")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_multicast(&self) -> bool {
|
||||
match self {
|
||||
@ -332,6 +336,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ip", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_documentation(&self) -> bool {
|
||||
match self {
|
||||
@ -356,6 +361,7 @@ impl IpAddr {
|
||||
/// assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0x2, 0, 0, 0, 0, 0, 0)).is_benchmarking(), true);
|
||||
/// ```
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_benchmarking(&self) -> bool {
|
||||
match self {
|
||||
@ -379,6 +385,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ip", since = "1.50.0")]
|
||||
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_ipv4(&self) -> bool {
|
||||
matches!(self, IpAddr::V4(_))
|
||||
@ -399,6 +406,7 @@ impl IpAddr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ip", since = "1.50.0")]
|
||||
#[stable(feature = "ipaddr_checker", since = "1.16.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_ipv6(&self) -> bool {
|
||||
matches!(self, IpAddr::V6(_))
|
||||
@ -527,6 +535,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")]
|
||||
#[stable(feature = "ip_shared", since = "1.12.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unspecified(&self) -> bool {
|
||||
self.inner.s_addr == 0
|
||||
@ -548,6 +557,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_loopback(&self) -> bool {
|
||||
self.octets()[0] == 127
|
||||
@ -578,6 +588,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_private(&self) -> bool {
|
||||
match self.octets() {
|
||||
@ -605,6 +616,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_link_local(&self) -> bool {
|
||||
matches!(self.octets(), [169, 254, ..])
|
||||
@ -680,6 +692,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_global(&self) -> bool {
|
||||
// check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two
|
||||
@ -720,6 +733,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_shared(&self) -> bool {
|
||||
self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
|
||||
@ -745,6 +759,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_benchmarking(&self) -> bool {
|
||||
self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18
|
||||
@ -779,6 +794,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_reserved(&self) -> bool {
|
||||
self.octets()[0] & 240 == 240 && !self.is_broadcast()
|
||||
@ -802,6 +818,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_multicast(&self) -> bool {
|
||||
self.octets()[0] >= 224 && self.octets()[0] <= 239
|
||||
@ -823,6 +840,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_broadcast(&self) -> bool {
|
||||
u32::from_be_bytes(self.octets()) == u32::from_be_bytes(Self::BROADCAST.octets())
|
||||
@ -850,6 +868,7 @@ impl Ipv4Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_documentation(&self) -> bool {
|
||||
match self.octets() {
|
||||
@ -1291,6 +1310,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unspecified(&self) -> bool {
|
||||
u128::from_be_bytes(self.octets()) == u128::from_be_bytes(Ipv6Addr::UNSPECIFIED.octets())
|
||||
@ -1314,6 +1334,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_loopback(&self) -> bool {
|
||||
u128::from_be_bytes(self.octets()) == u128::from_be_bytes(Ipv6Addr::LOCALHOST.octets())
|
||||
@ -1340,6 +1361,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_global(&self) -> bool {
|
||||
match self.multicast_scope() {
|
||||
@ -1367,6 +1389,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unique_local(&self) -> bool {
|
||||
(self.segments()[0] & 0xfe00) == 0xfc00
|
||||
@ -1395,6 +1418,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unicast(&self) -> bool {
|
||||
!self.is_multicast()
|
||||
@ -1446,6 +1470,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unicast_link_local(&self) -> bool {
|
||||
(self.segments()[0] & 0xffc0) == 0xfe80
|
||||
@ -1470,6 +1495,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_documentation(&self) -> bool {
|
||||
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8)
|
||||
@ -1492,6 +1518,7 @@ impl Ipv6Addr {
|
||||
/// assert_eq!(Ipv6Addr::new(0x2001, 0x2, 0, 0, 0, 0, 0, 0).is_benchmarking(), true);
|
||||
/// ```
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_benchmarking(&self) -> bool {
|
||||
(self.segments()[0] == 0x2001) && (self.segments()[1] == 0x2) && (self.segments()[2] == 0)
|
||||
@ -1529,6 +1556,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_unstable(feature = "const_ipv6", issue = "76205")]
|
||||
#[unstable(feature = "ip", issue = "27709")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_unicast_global(&self) -> bool {
|
||||
self.is_unicast()
|
||||
@ -1590,6 +1618,7 @@ impl Ipv6Addr {
|
||||
/// ```
|
||||
#[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")]
|
||||
#[stable(since = "1.7.0", feature = "ip_17")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn is_multicast(&self) -> bool {
|
||||
(self.segments()[0] & 0xff00) == 0xff00
|
||||
|
@ -156,6 +156,7 @@ impl SocketAddr {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "unix_socket", since = "1.10.0")]
|
||||
pub fn is_unnamed(&self) -> bool {
|
||||
if let AddressKind::Unnamed = self.address() { true } else { false }
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ impl BarrierWaitResult {
|
||||
/// println!("{:?}", barrier_wait_result.is_leader());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
pub fn is_leader(&self) -> bool {
|
||||
self.0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user