diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-11-29 12:14:03 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-11-29 21:11:20 -0800 |
| commit | a850bb0e5d07212ae716f447f3f69f6e4ce467da (patch) | |
| tree | 2915b18366da7635096986b24d0cf97739f1fd56 /src/libstd | |
| parent | 78fcf338833bd265c7f8dd1e46caf02b66039bb8 (diff) | |
| download | rust-a850bb0e5d07212ae716f447f3f69f6e4ce467da.tar.gz rust-a850bb0e5d07212ae716f447f3f69f6e4ce467da.zip | |
Update bootstrap compiler
Also remove a number of `stage0` annotations and such
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 200 |
1 files changed, 0 insertions, 200 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 312da203574..92507a73bae 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -298,198 +298,6 @@ pub trait AsciiExt { fn is_ascii_control(&self) -> bool { unimplemented!(); } } -// FIXME(LukasKalbertodt): this impl block can be removed in the future. This is -// possible once the stage0 compiler is new enough to contain the inherent -// ascii methods for `[str]`. See FIXME comment further down. -#[cfg(stage0)] -#[stable(feature = "rust1", since = "1.0.0")] -impl AsciiExt for str { - type Owned = String; - - #[inline] - fn is_ascii(&self) -> bool { - self.bytes().all(|b| b.is_ascii()) - } - - #[inline] - fn to_ascii_uppercase(&self) -> String { - let mut bytes = self.as_bytes().to_vec(); - bytes.make_ascii_uppercase(); - // make_ascii_uppercase() preserves the UTF-8 invariant. - unsafe { String::from_utf8_unchecked(bytes) } - } - - #[inline] - fn to_ascii_lowercase(&self) -> String { - let mut bytes = self.as_bytes().to_vec(); - bytes.make_ascii_lowercase(); - // make_ascii_uppercase() preserves the UTF-8 invariant. - unsafe { String::from_utf8_unchecked(bytes) } - } - - #[inline] - fn eq_ignore_ascii_case(&self, other: &str) -> bool { - self.as_bytes().eq_ignore_ascii_case(other.as_bytes()) - } - - fn make_ascii_uppercase(&mut self) { - let me = unsafe { self.as_bytes_mut() }; - me.make_ascii_uppercase() - } - - fn make_ascii_lowercase(&mut self) { - let me = unsafe { self.as_bytes_mut() }; - me.make_ascii_lowercase() - } - - #[inline] - fn is_ascii_alphabetic(&self) -> bool { - self.bytes().all(|b| b.is_ascii_alphabetic()) - } - - #[inline] - fn is_ascii_uppercase(&self) -> bool { - self.bytes().all(|b| b.is_ascii_uppercase()) - } - - #[inline] - fn is_ascii_lowercase(&self) -> bool { - self.bytes().all(|b| b.is_ascii_lowercase()) - } - - #[inline] - fn is_ascii_alphanumeric(&self) -> bool { - self.bytes().all(|b| b.is_ascii_alphanumeric()) - } - - #[inline] - fn is_ascii_digit(&self) -> bool { - self.bytes().all(|b| b.is_ascii_digit()) - } - - #[inline] - fn is_ascii_hexdigit(&self) -> bool { - self.bytes().all(|b| b.is_ascii_hexdigit()) - } - - #[inline] - fn is_ascii_punctuation(&self) -> bool { - self.bytes().all(|b| b.is_ascii_punctuation()) - } - - #[inline] - fn is_ascii_graphic(&self) -> bool { - self.bytes().all(|b| b.is_ascii_graphic()) - } - - #[inline] - fn is_ascii_whitespace(&self) -> bool { - self.bytes().all(|b| b.is_ascii_whitespace()) - } - - #[inline] - fn is_ascii_control(&self) -> bool { - self.bytes().all(|b| b.is_ascii_control()) - } -} - -// FIXME(LukasKalbertodt): this impl block can be removed in the future. This is -// possible once the stage0 compiler is new enough to contain the inherent -// ascii methods for `[u8]`. See FIXME comment further down. -#[cfg(stage0)] -#[stable(feature = "rust1", since = "1.0.0")] -impl AsciiExt for [u8] { - type Owned = Vec<u8>; - #[inline] - fn is_ascii(&self) -> bool { - self.iter().all(|b| b.is_ascii()) - } - - #[inline] - fn to_ascii_uppercase(&self) -> Vec<u8> { - let mut me = self.to_vec(); - me.make_ascii_uppercase(); - return me - } - - #[inline] - fn to_ascii_lowercase(&self) -> Vec<u8> { - let mut me = self.to_vec(); - me.make_ascii_lowercase(); - return me - } - - #[inline] - fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool { - self.len() == other.len() && - self.iter().zip(other).all(|(a, b)| { - a.eq_ignore_ascii_case(b) - }) - } - - fn make_ascii_uppercase(&mut self) { - for byte in self { - byte.make_ascii_uppercase(); - } - } - - fn make_ascii_lowercase(&mut self) { - for byte in self { - byte.make_ascii_lowercase(); - } - } - - #[inline] - fn is_ascii_alphabetic(&self) -> bool { - self.iter().all(|b| b.is_ascii_alphabetic()) - } - - #[inline] - fn is_ascii_uppercase(&self) -> bool { - self.iter().all(|b| b.is_ascii_uppercase()) - } - - #[inline] - fn is_ascii_lowercase(&self) -> bool { - self.iter().all(|b| b.is_ascii_lowercase()) - } - - #[inline] - fn is_ascii_alphanumeric(&self) -> bool { - self.iter().all(|b| b.is_ascii_alphanumeric()) - } - - #[inline] - fn is_ascii_digit(&self) -> bool { - self.iter().all(|b| b.is_ascii_digit()) - } - - #[inline] - fn is_ascii_hexdigit(&self) -> bool { - self.iter().all(|b| b.is_ascii_hexdigit()) - } - - #[inline] - fn is_ascii_punctuation(&self) -> bool { - self.iter().all(|b| b.is_ascii_punctuation()) - } - - #[inline] - fn is_ascii_graphic(&self) -> bool { - self.iter().all(|b| b.is_ascii_graphic()) - } - - #[inline] - fn is_ascii_whitespace(&self) -> bool { - self.iter().all(|b| b.is_ascii_whitespace()) - } - - #[inline] - fn is_ascii_control(&self) -> bool { - self.iter().all(|b| b.is_ascii_control()) - } -} - macro_rules! delegating_ascii_methods { () => { #[inline] @@ -562,10 +370,6 @@ impl AsciiExt for char { delegating_ascii_ctype_methods!(); } -// FIXME(LukasKalbertodt): the macro invocation should replace the impl block -// for `[u8]` above. But this is not possible until the stage0 compiler is new -// enough to contain the inherent ascii methods for `[u8]`. -#[cfg(not(stage0))] #[stable(feature = "rust1", since = "1.0.0")] impl AsciiExt for [u8] { type Owned = Vec<u8>; @@ -623,10 +427,6 @@ impl AsciiExt for [u8] { } } -// FIXME(LukasKalbertodt): the macro invocation should replace the impl block -// for `str` above. But this is not possible until the stage0 compiler is new -// enough to contain the inherent ascii methods for `str`. -#[cfg(not(stage0))] #[stable(feature = "rust1", since = "1.0.0")] impl AsciiExt for str { type Owned = String; |
