diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index 43fa612de6c50..e6c3d38dab3a2 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -779,7 +779,7 @@ impl BinaryHeap { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns + /// In other words, remove all elements `e` for which `f(&e)` returns /// `false`. The elements are visited in unsorted (and unspecified) order. /// /// # Examples diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 6d00642e03b22..d0ff3eb747598 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -963,7 +963,7 @@ impl BTreeMap { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// In other words, remove all pairs `(k, v)` for which `f(&k, &mut v)` returns `false`. /// The elements are visited in ascending key order. /// /// # Examples diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 405833720b37c..d6733425288d4 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -873,7 +873,7 @@ impl BTreeSet { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// In other words, remove all elements `e` for which `f(&e)` returns `false`. /// The elements are visited in ascending order. /// /// # Examples diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 7139a0fb94d76..c3cabc754e6a8 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2119,7 +2119,7 @@ impl VecDeque { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns false. + /// In other words, remove all elements `e` for which `f(&e)` returns false. /// This method operates in place, visiting each element exactly once in the /// original order, and preserves the order of the retained elements. /// @@ -2158,7 +2158,7 @@ impl VecDeque { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns false. + /// In other words, remove all elements `e` for which `f(&e)` returns false. /// This method operates in place, visiting each element exactly once in the /// original order, and preserves the order of the retained elements. /// diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 32590a2996c01..5131168db0c82 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1424,7 +1424,7 @@ impl Vec { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// In other words, remove all elements `e` for which `f(&e)` returns `false`. /// This method operates in place, visiting each element exactly once in the /// original order, and preserves the order of the retained elements. /// diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 1ebd1c58f2b59..5bdd78aa2dea4 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -989,3 +989,104 @@ macro_rules! nonzero_unsigned_is_power_of_two { } nonzero_unsigned_is_power_of_two! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize } + +macro_rules! nonzero_min_max_unsigned { + ( $( $Ty: ident($Int: ident); )+ ) => { + $( + impl $Ty { + /// The smallest value that can be represented by this non-zero + /// integer type, 1. + /// + /// # Examples + /// + /// ``` + /// #![feature(nonzero_min_max)] + #[doc = concat!("# use std::num::", stringify!($Ty), ";")] + /// + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), 1", stringify!($Int), ");")] + /// ``` + #[unstable(feature = "nonzero_min_max", issue = "89065")] + pub const MIN: Self = Self::new(1).unwrap(); + + /// The largest value that can be represented by this non-zero + /// integer type, + #[doc = concat!("equal to [`", stringify!($Int), "::MAX`].")] + /// + /// # Examples + /// + /// ``` + /// #![feature(nonzero_min_max)] + #[doc = concat!("# use std::num::", stringify!($Ty), ";")] + /// + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")] + /// ``` + #[unstable(feature = "nonzero_min_max", issue = "89065")] + pub const MAX: Self = Self::new(<$Int>::MAX).unwrap(); + } + )+ + } +} + +macro_rules! nonzero_min_max_signed { + ( $( $Ty: ident($Int: ident); )+ ) => { + $( + impl $Ty { + /// The smallest value that can be represented by this non-zero + /// integer type, + #[doc = concat!("equal to [`", stringify!($Int), "::MIN`].")] + /// + /// Note: While most integer types are defined for every whole + /// number between `MIN` and `MAX`, signed non-zero integers are + /// a special case. They have a "gap" at 0. + /// + /// # Examples + /// + /// ``` + /// #![feature(nonzero_min_max)] + #[doc = concat!("# use std::num::", stringify!($Ty), ";")] + /// + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), ", stringify!($Int), "::MIN);")] + /// ``` + #[unstable(feature = "nonzero_min_max", issue = "89065")] + pub const MIN: Self = Self::new(<$Int>::MIN).unwrap(); + + /// The largest value that can be represented by this non-zero + /// integer type, + #[doc = concat!("equal to [`", stringify!($Int), "::MAX`].")] + /// + /// Note: While most integer types are defined for every whole + /// number between `MIN` and `MAX`, signed non-zero integers are + /// a special case. They have a "gap" at 0. + /// + /// # Examples + /// + /// ``` + /// #![feature(nonzero_min_max)] + #[doc = concat!("# use std::num::", stringify!($Ty), ";")] + /// + #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")] + /// ``` + #[unstable(feature = "nonzero_min_max", issue = "89065")] + pub const MAX: Self = Self::new(<$Int>::MAX).unwrap(); + } + )+ + } +} + +nonzero_min_max_unsigned! { + NonZeroU8(u8); + NonZeroU16(u16); + NonZeroU32(u32); + NonZeroU64(u64); + NonZeroU128(u128); + NonZeroUsize(usize); +} + +nonzero_min_max_signed! { + NonZeroI8(i8); + NonZeroI16(i16); + NonZeroI32(i32); + NonZeroI64(i64); + NonZeroI128(i128); + NonZeroIsize(isize); +} diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 7d0c375cd4f5f..de1628f83ade8 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -551,7 +551,7 @@ impl Option { matches!(*self, Some(_)) } - /// Returns `true` if the option is a [`Some`] wrapping a value matching the predicate. + /// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate. /// /// # Examples /// @@ -559,18 +559,18 @@ impl Option { /// #![feature(is_some_with)] /// /// let x: Option = Some(2); - /// assert_eq!(x.is_some_with(|&x| x > 1), true); + /// assert_eq!(x.is_some_and(|&x| x > 1), true); /// /// let x: Option = Some(0); - /// assert_eq!(x.is_some_with(|&x| x > 1), false); + /// assert_eq!(x.is_some_and(|&x| x > 1), false); /// /// let x: Option = None; - /// assert_eq!(x.is_some_with(|&x| x > 1), false); + /// assert_eq!(x.is_some_and(|&x| x > 1), false); /// ``` #[must_use] #[inline] #[unstable(feature = "is_some_with", issue = "93050")] - pub fn is_some_with(&self, f: impl FnOnce(&T) -> bool) -> bool { + pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool { matches!(self, Some(x) if f(x)) } diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 2d739bf295b92..9a243cbc3a2a0 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -542,7 +542,7 @@ impl Result { matches!(*self, Ok(_)) } - /// Returns `true` if the result is [`Ok`] wrapping a value matching the predicate. + /// Returns `true` if the result is [`Ok`] and the value inside of it matches a predicate. /// /// # Examples /// @@ -550,18 +550,18 @@ impl Result { /// #![feature(is_some_with)] /// /// let x: Result = Ok(2); - /// assert_eq!(x.is_ok_with(|&x| x > 1), true); + /// assert_eq!(x.is_ok_and(|&x| x > 1), true); /// /// let x: Result = Ok(0); - /// assert_eq!(x.is_ok_with(|&x| x > 1), false); + /// assert_eq!(x.is_ok_and(|&x| x > 1), false); /// /// let x: Result = Err("hey"); - /// assert_eq!(x.is_ok_with(|&x| x > 1), false); + /// assert_eq!(x.is_ok_and(|&x| x > 1), false); /// ``` #[must_use] #[inline] #[unstable(feature = "is_some_with", issue = "93050")] - pub fn is_ok_with(&self, f: impl FnOnce(&T) -> bool) -> bool { + pub fn is_ok_and(&self, f: impl FnOnce(&T) -> bool) -> bool { matches!(self, Ok(x) if f(x)) } @@ -586,7 +586,7 @@ impl Result { !self.is_ok() } - /// Returns `true` if the result is [`Err`] wrapping a value matching the predicate. + /// Returns `true` if the result is [`Err`] and the value inside of it matches a predicate. /// /// # Examples /// @@ -595,18 +595,18 @@ impl Result { /// use std::io::{Error, ErrorKind}; /// /// let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); - /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true); + /// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true); /// /// let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); - /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false); + /// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); /// /// let x: Result = Ok(123); - /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false); + /// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); /// ``` #[must_use] #[inline] #[unstable(feature = "is_some_with", issue = "93050")] - pub fn is_err_with(&self, f: impl FnOnce(&E) -> bool) -> bool { + pub fn is_err_and(&self, f: impl FnOnce(&E) -> bool) -> bool { matches!(self, Err(x) if f(x)) } diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index b5dd17d99296b..6b63191eb583d 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -621,7 +621,7 @@ impl HashMap { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// In other words, remove all pairs `(k, v)` for which `f(&k, &mut v)` returns `false`. /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 876d05b50fb80..fa471a3c3f323 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -300,7 +300,7 @@ impl HashSet { /// Retains only the elements specified by the predicate. /// - /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// In other words, remove all elements `e` for which `f(&e)` returns `false`. /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index ba65d8f285e48..a3ef4b2d92cc4 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -140,12 +140,11 @@ impl SocketAddr { /// # Examples /// /// ``` - /// #![feature(unix_socket_creation)] /// use std::os::unix::net::SocketAddr; /// use std::path::Path; /// /// # fn main() -> std::io::Result<()> { - /// let address = SocketAddr::from_path("/path/to/socket")?; + /// let address = SocketAddr::from_pathname("/path/to/socket")?; /// assert_eq!(address.as_pathname(), Some(Path::new("/path/to/socket"))); /// # Ok(()) /// # } @@ -154,13 +153,12 @@ impl SocketAddr { /// Creating a `SocketAddr` with a NULL byte results in an error. /// /// ``` - /// #![feature(unix_socket_creation)] /// use std::os::unix::net::SocketAddr; /// - /// assert!(SocketAddr::from_path("/path/with/\0/bytes").is_err()); + /// assert!(SocketAddr::from_pathname("/path/with/\0/bytes").is_err()); /// ``` - #[unstable(feature = "unix_socket_creation", issue = "93423")] - pub fn from_path

(path: P) -> io::Result + #[stable(feature = "unix_socket_creation", since = "1.61.0")] + pub fn from_pathname

(path: P) -> io::Result where P: AsRef, { diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 94424cb4548fa..87a130a09827d 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -279,6 +279,10 @@ def build(): def set(key, value): + if isinstance(value, list): + # Remove empty values, which value.split(',') tends to generate. + value = [v for v in value if v] + s = "{:20} := {}".format(key, value) if len(s) < 70: p(s)