Skip to content

Commit 151be09

Browse files
committed
Auto merge of #32314 - alexcrichton:ascii-fun, r=aturon
std: Revert addition of `into_ascii_*` methods The addition of these methods in #31335 required adding impls of the trait for the `String` and `Vec<T>` types. This unfortunately caused a regression (#32074) in type inference for using these methods which the libs team has decided to not push forward with. These methods were stabilized in #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 #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, #27809. Closes #32074
2 parents 7c66a89 + af65d81 commit 151be09

File tree

1 file changed

+0
-102
lines changed

1 file changed

+0
-102
lines changed

src/libstd/ascii.rs

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -160,108 +160,6 @@ pub trait AsciiExt {
160160
/// ```
161161
#[unstable(feature = "ascii", issue = "27809")]
162162
fn make_ascii_lowercase(&mut self);
163-
164-
/// Converts this type to its ASCII upper case,
165-
/// consuming the value to avoid allocating memory where `to_ascii_uppercase` would.
166-
///
167-
/// See `to_ascii_uppercase` for more information.
168-
///
169-
/// # Examples
170-
///
171-
/// ```
172-
/// use std::ascii::AsciiExt;
173-
///
174-
/// let ascii: String = "a".to_owned();
175-
///
176-
/// let upper = ascii.into_ascii_uppercase();
177-
///
178-
/// assert_eq!(upper, "A");
179-
/// ```
180-
#[stable(feature = "into_ascii", since = "1.8.0")]
181-
fn into_ascii_uppercase(self) -> Self::Owned where Self: Sized {
182-
self.to_ascii_uppercase()
183-
}
184-
185-
/// Converts this type to its ASCII lower case,
186-
/// consuming the value to avoid allocating memory where `to_ascii_lowercase` would.
187-
///
188-
/// See `to_ascii_lowercase` for more information.
189-
///
190-
/// # Examples
191-
///
192-
/// ```
193-
/// use std::ascii::AsciiExt;
194-
///
195-
/// let ascii: String = "A".to_owned();
196-
///
197-
/// let lower = ascii.into_ascii_lowercase();
198-
///
199-
/// assert_eq!(lower, "a");
200-
/// ```
201-
#[stable(feature = "into_ascii", since = "1.8.0")]
202-
fn into_ascii_lowercase(self) -> Self::Owned where Self: Sized {
203-
self.to_ascii_lowercase()
204-
}
205-
}
206-
207-
/// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation,
208-
/// defer other methods to `str`.
209-
#[stable(feature = "into_ascii", since = "1.8.0")]
210-
impl AsciiExt for String {
211-
type Owned = Self;
212-
213-
#[inline] fn is_ascii(&self) -> bool { (**self).is_ascii() }
214-
#[inline] fn to_ascii_uppercase(&self) -> Self { (**self).to_ascii_uppercase() }
215-
#[inline] fn to_ascii_lowercase(&self) -> Self { (**self).to_ascii_lowercase() }
216-
#[inline] fn eq_ignore_ascii_case(&self, o: &Self) -> bool { (**self).eq_ignore_ascii_case(o) }
217-
#[inline] fn make_ascii_uppercase(&mut self) { (**self).make_ascii_uppercase() }
218-
#[inline] fn make_ascii_lowercase(&mut self) { (**self).make_ascii_lowercase() }
219-
220-
fn into_ascii_lowercase(mut self) -> Self {
221-
unsafe {
222-
for byte in self.as_mut_vec() {
223-
*byte = byte.to_ascii_lowercase()
224-
}
225-
}
226-
self
227-
}
228-
229-
fn into_ascii_uppercase(mut self) -> Self {
230-
unsafe {
231-
for byte in self.as_mut_vec() {
232-
*byte = byte.to_ascii_uppercase()
233-
}
234-
}
235-
self
236-
}
237-
}
238-
239-
/// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation,
240-
/// defer other methods to `[u8]`.
241-
#[stable(feature = "into_ascii", since = "1.8.0")]
242-
impl AsciiExt for Vec<u8> {
243-
type Owned = Self;
244-
245-
#[inline] fn is_ascii(&self) -> bool { (**self).is_ascii() }
246-
#[inline] fn to_ascii_uppercase(&self) -> Self { (**self).to_ascii_uppercase() }
247-
#[inline] fn to_ascii_lowercase(&self) -> Self { (**self).to_ascii_lowercase() }
248-
#[inline] fn eq_ignore_ascii_case(&self, o: &Self) -> bool { (**self).eq_ignore_ascii_case(o) }
249-
#[inline] fn make_ascii_uppercase(&mut self) { (**self).make_ascii_uppercase() }
250-
#[inline] fn make_ascii_lowercase(&mut self) { (**self).make_ascii_lowercase() }
251-
252-
fn into_ascii_lowercase(mut self) -> Self {
253-
for byte in &mut self {
254-
*byte = byte.to_ascii_lowercase()
255-
}
256-
self
257-
}
258-
259-
fn into_ascii_uppercase(mut self) -> Self {
260-
for byte in &mut self {
261-
*byte = byte.to_ascii_uppercase()
262-
}
263-
self
264-
}
265163
}
266164

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

0 commit comments

Comments
 (0)