Skip to content

Commit

Permalink
std: Revert addition of into_ascii_* methods
Browse files Browse the repository at this point in the history
The addition of these methods in rust-lang#31335 required adding impls of the trait for
the `String` and `Vec<T>` types. This unfortunately caused a regression (rust-lang#32074)
in type inference for using these methods which the libs team has decided to not
push forward with. These methods were stabilized in rust-lang#32020 which was intended to
get backported to beta, but the backport hasn't happened just yet. This commit
reverts both the addition and stabilization of these methods.

One proposed method of handling this, in rust-lang#32076, was to move the methods to an
extra trait to avoid conflicts with type inference. After some discussion,
however, the libs team concluded that we probably want to reevaluate what we're
doing here, so discussion will continue on the tracking issue, rust-lang#27809.
  • Loading branch information
alexcrichton committed Mar 17, 2016
1 parent e68d40e commit af65d81
Showing 1 changed file with 0 additions and 102 deletions.
102 changes: 0 additions & 102 deletions src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,108 +160,6 @@ pub trait AsciiExt {
/// ```
#[unstable(feature = "ascii", issue = "27809")]
fn make_ascii_lowercase(&mut self);

/// Converts this type to its ASCII upper case,
/// consuming the value to avoid allocating memory where `to_ascii_uppercase` would.
///
/// See `to_ascii_uppercase` for more information.
///
/// # Examples
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let ascii: String = "a".to_owned();
///
/// let upper = ascii.into_ascii_uppercase();
///
/// assert_eq!(upper, "A");
/// ```
#[stable(feature = "into_ascii", since = "1.8.0")]
fn into_ascii_uppercase(self) -> Self::Owned where Self: Sized {
self.to_ascii_uppercase()
}

/// Converts this type to its ASCII lower case,
/// consuming the value to avoid allocating memory where `to_ascii_lowercase` would.
///
/// See `to_ascii_lowercase` for more information.
///
/// # Examples
///
/// ```
/// use std::ascii::AsciiExt;
///
/// let ascii: String = "A".to_owned();
///
/// let lower = ascii.into_ascii_lowercase();
///
/// assert_eq!(lower, "a");
/// ```
#[stable(feature = "into_ascii", since = "1.8.0")]
fn into_ascii_lowercase(self) -> Self::Owned where Self: Sized {
self.to_ascii_lowercase()
}
}

/// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation,
/// defer other methods to `str`.
#[stable(feature = "into_ascii", since = "1.8.0")]
impl AsciiExt for String {
type Owned = Self;

#[inline] fn is_ascii(&self) -> bool { (**self).is_ascii() }
#[inline] fn to_ascii_uppercase(&self) -> Self { (**self).to_ascii_uppercase() }
#[inline] fn to_ascii_lowercase(&self) -> Self { (**self).to_ascii_lowercase() }
#[inline] fn eq_ignore_ascii_case(&self, o: &Self) -> bool { (**self).eq_ignore_ascii_case(o) }
#[inline] fn make_ascii_uppercase(&mut self) { (**self).make_ascii_uppercase() }
#[inline] fn make_ascii_lowercase(&mut self) { (**self).make_ascii_lowercase() }

fn into_ascii_lowercase(mut self) -> Self {
unsafe {
for byte in self.as_mut_vec() {
*byte = byte.to_ascii_lowercase()
}
}
self
}

fn into_ascii_uppercase(mut self) -> Self {
unsafe {
for byte in self.as_mut_vec() {
*byte = byte.to_ascii_uppercase()
}
}
self
}
}

/// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation,
/// defer other methods to `[u8]`.
#[stable(feature = "into_ascii", since = "1.8.0")]
impl AsciiExt for Vec<u8> {
type Owned = Self;

#[inline] fn is_ascii(&self) -> bool { (**self).is_ascii() }
#[inline] fn to_ascii_uppercase(&self) -> Self { (**self).to_ascii_uppercase() }
#[inline] fn to_ascii_lowercase(&self) -> Self { (**self).to_ascii_lowercase() }
#[inline] fn eq_ignore_ascii_case(&self, o: &Self) -> bool { (**self).eq_ignore_ascii_case(o) }
#[inline] fn make_ascii_uppercase(&mut self) { (**self).make_ascii_uppercase() }
#[inline] fn make_ascii_lowercase(&mut self) { (**self).make_ascii_lowercase() }

fn into_ascii_lowercase(mut self) -> Self {
for byte in &mut self {
*byte = byte.to_ascii_lowercase()
}
self
}

fn into_ascii_uppercase(mut self) -> Self {
for byte in &mut self {
*byte = byte.to_ascii_uppercase()
}
self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit af65d81

Please sign in to comment.