Skip to content

Commit

Permalink
Auto merge of #50088 - alexcrichton:std-tweaks, r=sfackler
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 20, 2018
2 parents 05dc5e7 + ca79ba3 commit a10bb6b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2155,8 +2155,8 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
/// assert_eq!(map["poneyland"], 43);
/// ```
#[stable(feature = "entry_and_modify", since = "1.26.0")]
pub fn and_modify<F>(self, mut f: F) -> Self
where F: FnMut(&mut V)
pub fn and_modify<F>(self, f: F) -> Self
where F: FnOnce(&mut V)
{
match self {
Occupied(mut entry) => {
Expand Down
42 changes: 0 additions & 42 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,48 +2140,6 @@ impl str {
unsafe { String::from_utf8_unchecked(buf) }
}

/// Returns true if this `str` is entirely whitespace, and false otherwise.
///
/// 'Whitespace' is defined according to the terms of the Unicode Derived Core
/// Property `White_Space`.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// assert!(" \t ".is_whitespace());
///
/// // a non-breaking space
/// assert!("\u{A0}".is_whitespace());
///
/// assert!(!" 越".is_whitespace());
/// ```
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
#[inline]
pub fn is_whitespace(&self) -> bool {
StrExt::is_whitespace(self)
}

/// Returns true if this `str` is entirely alphanumeric, and false otherwise.
///
/// 'Alphanumeric'-ness is defined in terms of the Unicode General Categories
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// assert!("٣7৬Kو藏".is_alphanumeric());
/// assert!(!"¾①".is_alphanumeric());
/// ```
#[stable(feature = "unicode_methods_on_intrinsics", since = "1.27.0")]
#[inline]
pub fn is_alphanumeric(&self) -> bool {
StrExt::is_alphanumeric(self)
}

/// Checks if all characters in this string are within the ASCII range.
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ fn partition_source(s: &str) -> (String, String) {

for line in s.lines() {
let trimline = line.trim();
let header = trimline.is_whitespace() ||
let header = trimline.chars().all(|c| c.is_whitespace()) ||
trimline.starts_with("#![") ||
trimline.starts_with("#[macro_use] extern crate") ||
trimline.starts_with("extern crate");
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2126,8 +2126,8 @@ impl<'a, K, V> Entry<'a, K, V> {
/// assert_eq!(map["poneyland"], 43);
/// ```
#[stable(feature = "entry_and_modify", since = "1.26.0")]
pub fn and_modify<F>(self, mut f: F) -> Self
where F: FnMut(&mut V)
pub fn and_modify<F>(self, f: F) -> Self
where F: FnOnce(&mut V)
{
match self {
Occupied(mut entry) => {
Expand Down

0 comments on commit a10bb6b

Please sign in to comment.