Skip to content

Commit 222ca2d

Browse files
committed
[beta] 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 8423230 commit 222ca2d

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
@@ -2156,8 +2156,8 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
21562156
/// assert_eq!(map["poneyland"], 43);
21572157
/// ```
21582158
#[stable(feature = "entry_and_modify", since = "1.26.0")]
2159-
pub fn and_modify<F>(self, mut f: F) -> Self
2160-
where F: FnMut(&mut V)
2159+
pub fn and_modify<F>(self, f: F) -> Self
2160+
where F: FnOnce(&mut V)
21612161
{
21622162
match self {
21632163
Occupied(mut entry) => {

src/liballoc/str.rs

-42
Original file line numberDiff line numberDiff line change
@@ -2122,48 +2122,6 @@ impl str {
21222122
unsafe { String::from_utf8_unchecked(buf) }
21232123
}
21242124

2125-
/// Returns true if this `str` is entirely whitespace, and false otherwise.
2126-
///
2127-
/// 'Whitespace' is defined according to the terms of the Unicode Derived Core
2128-
/// Property `White_Space`.
2129-
///
2130-
/// # Examples
2131-
///
2132-
/// Basic usage:
2133-
///
2134-
/// ```
2135-
/// assert!(" \t ".is_whitespace());
2136-
///
2137-
/// // a non-breaking space
2138-
/// assert!("\u{A0}".is_whitespace());
2139-
///
2140-
/// assert!(!" 越".is_whitespace());
2141-
/// ```
2142-
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
2143-
#[inline]
2144-
pub fn is_whitespace(&self) -> bool {
2145-
UnicodeStr::is_whitespace(self)
2146-
}
2147-
2148-
/// Returns true if this `str` is entirely alphanumeric, and false otherwise.
2149-
///
2150-
/// 'Alphanumeric'-ness is defined in terms of the Unicode General Categories
2151-
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
2152-
///
2153-
/// # Examples
2154-
///
2155-
/// Basic usage:
2156-
///
2157-
/// ```
2158-
/// assert!("٣7৬Kو藏".is_alphanumeric());
2159-
/// assert!(!"¾①".is_alphanumeric());
2160-
/// ```
2161-
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
2162-
#[inline]
2163-
pub fn is_alphanumeric(&self) -> bool {
2164-
UnicodeStr::is_alphanumeric(self)
2165-
}
2166-
21672125
/// Checks if all characters in this string are within the ASCII range.
21682126
///
21692127
/// # Examples

src/librustdoc/test.rs

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

423423
for line in s.lines() {
424424
let trimline = line.trim();
425-
let header = trimline.is_whitespace() ||
425+
let header = trimline.chars().all(|c| c.is_whitespace()) ||
426426
trimline.starts_with("#![") ||
427427
trimline.starts_with("#[macro_use] extern crate") ||
428428
trimline.starts_with("extern crate");

src/libstd/collections/hash/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2204,8 +2204,8 @@ impl<'a, K, V> Entry<'a, K, V> {
22042204
/// assert_eq!(map["poneyland"], 43);
22052205
/// ```
22062206
#[stable(feature = "entry_and_modify", since = "1.26.0")]
2207-
pub fn and_modify<F>(self, mut f: F) -> Self
2208-
where F: FnMut(&mut V)
2207+
pub fn and_modify<F>(self, f: F) -> Self
2208+
where F: FnOnce(&mut V)
22092209
{
22102210
match self {
22112211
Occupied(mut entry) => {

0 commit comments

Comments
 (0)