Skip to content

Commit ca79ba3

Browse files
committed
Tweak some stabilizations in libstd
This commit tweaks a few stable APIs in the `beta` branch before they hit stable. The `str::is_whitespace` and `str::is_alphanumeric` functions were deleted (added in #49381, issue at #49657). The `and_modify` APIs added in #44734 were altered to take a `FnOnce` closure rather than a `FnMut` closure. Closes #49581 Closes #49657
1 parent 65d201f commit ca79ba3

File tree

4 files changed

+5
-47
lines changed

4 files changed

+5
-47
lines changed

src/liballoc/btree/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2155,8 +2155,8 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
21552155
/// assert_eq!(map["poneyland"], 43);
21562156
/// ```
21572157
#[stable(feature = "entry_and_modify", since = "1.26.0")]
2158-
pub fn and_modify<F>(self, mut f: F) -> Self
2159-
where F: FnMut(&mut V)
2158+
pub fn and_modify<F>(self, f: F) -> Self
2159+
where F: FnOnce(&mut V)
21602160
{
21612161
match self {
21622162
Occupied(mut entry) => {

src/liballoc/str.rs

-42
Original file line numberDiff line numberDiff line change
@@ -2140,48 +2140,6 @@ impl str {
21402140
unsafe { String::from_utf8_unchecked(buf) }
21412141
}
21422142

2143-
/// Returns true if this `str` is entirely whitespace, and false otherwise.
2144-
///
2145-
/// 'Whitespace' is defined according to the terms of the Unicode Derived Core
2146-
/// Property `White_Space`.
2147-
///
2148-
/// # Examples
2149-
///
2150-
/// Basic usage:
2151-
///
2152-
/// ```
2153-
/// assert!(" \t ".is_whitespace());
2154-
///
2155-
/// // a non-breaking space
2156-
/// assert!("\u{A0}".is_whitespace());
2157-
///
2158-
/// assert!(!" 越".is_whitespace());
2159-
/// ```
2160-
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
2161-
#[inline]
2162-
pub fn is_whitespace(&self) -> bool {
2163-
StrExt::is_whitespace(self)
2164-
}
2165-
2166-
/// Returns true if this `str` is entirely alphanumeric, and false otherwise.
2167-
///
2168-
/// 'Alphanumeric'-ness is defined in terms of the Unicode General Categories
2169-
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
2170-
///
2171-
/// # Examples
2172-
///
2173-
/// Basic usage:
2174-
///
2175-
/// ```
2176-
/// assert!("٣7৬Kو藏".is_alphanumeric());
2177-
/// assert!(!"¾①".is_alphanumeric());
2178-
/// ```
2179-
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
2180-
#[inline]
2181-
pub fn is_alphanumeric(&self) -> bool {
2182-
StrExt::is_alphanumeric(self)
2183-
}
2184-
21852143
/// Checks if all characters in this string are within the ASCII range.
21862144
///
21872145
/// # Examples

src/librustdoc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn partition_source(s: &str) -> (String, String) {
437437

438438
for line in s.lines() {
439439
let trimline = line.trim();
440-
let header = trimline.is_whitespace() ||
440+
let header = trimline.chars().all(|c| c.is_whitespace()) ||
441441
trimline.starts_with("#![") ||
442442
trimline.starts_with("#[macro_use] extern crate") ||
443443
trimline.starts_with("extern crate");

src/libstd/collections/hash/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2127,8 +2127,8 @@ impl<'a, K, V> Entry<'a, K, V> {
21272127
/// assert_eq!(map["poneyland"], 43);
21282128
/// ```
21292129
#[stable(feature = "entry_and_modify", since = "1.26.0")]
2130-
pub fn and_modify<F>(self, mut f: F) -> Self
2131-
where F: FnMut(&mut V)
2130+
pub fn and_modify<F>(self, f: F) -> Self
2131+
where F: FnOnce(&mut V)
21322132
{
21332133
match self {
21342134
Occupied(mut entry) => {

0 commit comments

Comments
 (0)