From 667f83d46baa1c42a170cfae5afbff52a85cd95d Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Thu, 9 Nov 2017 11:05:28 +0100 Subject: [PATCH 1/3] Remove inherent `ascii_ctype` methods from `str` and `[u8]` This has been discussed in #39658. It's a bit ambiguous how those methods work for a sequence of ascii values. We prefer users writing `s.iter().all(|b| b.is_ascii_...())` explicitly. The AsciiExt methods still exist and are implemented for `str` and `[u8]`. We will deprecated or remove those later. --- src/liballoc/slice.rs | 114 ----------------------- src/liballoc/str.rs | 147 ----------------------------- src/libstd/ascii.rs | 209 +++++++++++++++++++++++++++++++++--------- 3 files changed, 166 insertions(+), 304 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index b41cb912fe798..d2573e8d4422c 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -1626,120 +1626,6 @@ impl [u8] { byte.make_ascii_lowercase(); } } - - /// Checks if all bytes of this slice are ASCII alphabetic characters: - /// - /// - U+0041 'A' ... U+005A 'Z', or - /// - U+0061 'a' ... U+007A 'z'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_alphabetic(&self) -> bool { - self.iter().all(|b| b.is_ascii_alphabetic()) - } - - /// Checks if all bytes of this slice are ASCII uppercase characters: - /// U+0041 'A' ... U+005A 'Z'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_uppercase(&self) -> bool { - self.iter().all(|b| b.is_ascii_uppercase()) - } - - /// Checks if all bytes of this slice are ASCII lowercase characters: - /// U+0061 'a' ... U+007A 'z'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_lowercase(&self) -> bool { - self.iter().all(|b| b.is_ascii_lowercase()) - } - - /// Checks if all bytes of this slice are ASCII alphanumeric characters: - /// - /// - U+0041 'A' ... U+005A 'Z', or - /// - U+0061 'a' ... U+007A 'z', or - /// - U+0030 '0' ... U+0039 '9'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_alphanumeric(&self) -> bool { - self.iter().all(|b| b.is_ascii_alphanumeric()) - } - - /// Checks if all bytes of this slice are ASCII decimal digit: - /// U+0030 '0' ... U+0039 '9'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_digit(&self) -> bool { - self.iter().all(|b| b.is_ascii_digit()) - } - - /// Checks if all bytes of this slice are ASCII hexadecimal digits: - /// - /// - U+0030 '0' ... U+0039 '9', or - /// - U+0041 'A' ... U+0046 'F', or - /// - U+0061 'a' ... U+0066 'f'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_hexdigit(&self) -> bool { - self.iter().all(|b| b.is_ascii_hexdigit()) - } - - /// Checks if all bytes of this slice are ASCII punctuation characters: - /// - /// - U+0021 ... U+002F `! " # $ % & ' ( ) * + , - . /`, or - /// - U+003A ... U+0040 `: ; < = > ? @`, or - /// - U+005B ... U+0060 `[ \\ ] ^ _ \``, or - /// - U+007B ... U+007E `{ | } ~` - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_punctuation(&self) -> bool { - self.iter().all(|b| b.is_ascii_punctuation()) - } - - /// Checks if all bytes of this slice are ASCII graphic characters: - /// U+0021 '@' ... U+007E '~'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_graphic(&self) -> bool { - self.iter().all(|b| b.is_ascii_graphic()) - } - - /// Checks if all bytes of this slice are ASCII whitespace characters: - /// U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED, - /// U+000C FORM FEED, or U+000D CARRIAGE RETURN. - /// - /// Rust uses the WhatWG Infra Standard's [definition of ASCII - /// whitespace][infra-aw]. There are several other definitions in - /// wide use. For instance, [the POSIX locale][pct] includes - /// U+000B VERTICAL TAB as well as all the above characters, - /// but—from the very same specification—[the default rule for - /// "field splitting" in the Bourne shell][bfs] considers *only* - /// SPACE, HORIZONTAL TAB, and LINE FEED as whitespace. - /// - /// If you are writing a program that will process an existing - /// file format, check what that format's definition of whitespace is - /// before using this function. - /// - /// [infra-aw]: https://infra.spec.whatwg.org/#ascii-whitespace - /// [pct]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_01 - /// [bfs]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05 - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_whitespace(&self) -> bool { - self.iter().all(|b| b.is_ascii_whitespace()) - } - - /// Checks if all bytes of this slice are ASCII control characters: - /// - /// - U+0000 NUL ... U+001F UNIT SEPARATOR, or - /// - U+007F DELETE. - /// - /// Note that most ASCII whitespace characters are control - /// characters, but SPACE is not. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_control(&self) -> bool { - self.iter().all(|b| b.is_ascii_control()) - } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index f68ee847eb3ab..9173bda4248d3 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -2199,153 +2199,6 @@ impl str { let me = unsafe { self.as_bytes_mut() }; me.make_ascii_lowercase() } - - /// Checks if all characters of this string are ASCII alphabetic - /// characters: - /// - /// - U+0041 'A' ... U+005A 'Z', or - /// - U+0061 'a' ... U+007A 'z'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_alphabetic(&self) -> bool { - self.bytes().all(|b| b.is_ascii_alphabetic()) - } - - /// Checks if all characters of this string are ASCII uppercase characters: - /// U+0041 'A' ... U+005A 'Z'. - /// - /// # Example - /// - /// ``` - /// #![feature(ascii_ctype)] - /// - /// // Only ascii uppercase characters - /// assert!("HELLO".is_ascii_uppercase()); - /// - /// // While all characters are ascii, 'y' and 'e' are not uppercase - /// assert!(!"Bye".is_ascii_uppercase()); - /// - /// // While all characters are uppercase, 'Ü' is not ascii - /// assert!(!"TSCHÜSS".is_ascii_uppercase()); - /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_uppercase(&self) -> bool { - self.bytes().all(|b| b.is_ascii_uppercase()) - } - - /// Checks if all characters of this string are ASCII lowercase characters: - /// U+0061 'a' ... U+007A 'z'. - /// - /// # Example - /// - /// ``` - /// #![feature(ascii_ctype)] - /// - /// // Only ascii uppercase characters - /// assert!("hello".is_ascii_lowercase()); - /// - /// // While all characters are ascii, 'B' is not lowercase - /// assert!(!"Bye".is_ascii_lowercase()); - /// - /// // While all characters are lowercase, 'Ü' is not ascii - /// assert!(!"tschüss".is_ascii_lowercase()); - /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_lowercase(&self) -> bool { - self.bytes().all(|b| b.is_ascii_lowercase()) - } - - /// Checks if all characters of this string are ASCII alphanumeric - /// characters: - /// - /// - U+0041 'A' ... U+005A 'Z', or - /// - U+0061 'a' ... U+007A 'z', or - /// - U+0030 '0' ... U+0039 '9'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_alphanumeric(&self) -> bool { - self.bytes().all(|b| b.is_ascii_alphanumeric()) - } - - /// Checks if all characters of this string are ASCII decimal digit: - /// U+0030 '0' ... U+0039 '9'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_digit(&self) -> bool { - self.bytes().all(|b| b.is_ascii_digit()) - } - - /// Checks if all characters of this string are ASCII hexadecimal digits: - /// - /// - U+0030 '0' ... U+0039 '9', or - /// - U+0041 'A' ... U+0046 'F', or - /// - U+0061 'a' ... U+0066 'f'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_hexdigit(&self) -> bool { - self.bytes().all(|b| b.is_ascii_hexdigit()) - } - - /// Checks if all characters of this string are ASCII punctuation - /// characters: - /// - /// - U+0021 ... U+002F `! " # $ % & ' ( ) * + , - . /`, or - /// - U+003A ... U+0040 `: ; < = > ? @`, or - /// - U+005B ... U+0060 ``[ \ ] ^ _ ` ``, or - /// - U+007B ... U+007E `{ | } ~` - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_punctuation(&self) -> bool { - self.bytes().all(|b| b.is_ascii_punctuation()) - } - - /// Checks if all characters of this string are ASCII graphic characters: - /// U+0021 '@' ... U+007E '~'. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_graphic(&self) -> bool { - self.bytes().all(|b| b.is_ascii_graphic()) - } - - /// Checks if all characters of this string are ASCII whitespace characters: - /// U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED, - /// U+000C FORM FEED, or U+000D CARRIAGE RETURN. - /// - /// Rust uses the WhatWG Infra Standard's [definition of ASCII - /// whitespace][infra-aw]. There are several other definitions in - /// wide use. For instance, [the POSIX locale][pct] includes - /// U+000B VERTICAL TAB as well as all the above characters, - /// but—from the very same specification—[the default rule for - /// "field splitting" in the Bourne shell][bfs] considers *only* - /// SPACE, HORIZONTAL TAB, and LINE FEED as whitespace. - /// - /// If you are writing a program that will process an existing - /// file format, check what that format's definition of whitespace is - /// before using this function. - /// - /// [infra-aw]: https://infra.spec.whatwg.org/#ascii-whitespace - /// [pct]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_01 - /// [bfs]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05 - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_whitespace(&self) -> bool { - self.bytes().all(|b| b.is_ascii_whitespace()) - } - - /// Checks if all characters of this string are ASCII control characters: - /// - /// - U+0000 NUL ... U+001F UNIT SEPARATOR, or - /// - U+007F DELETE. - /// - /// Note that most ASCII whitespace characters are control - /// characters, but SPACE is not. - #[unstable(feature = "ascii_ctype", issue = "39658")] - #[inline] - pub fn is_ascii_control(&self) -> bool { - self.bytes().all(|b| b.is_ascii_control()) - } } /// Converts a boxed slice of bytes to a boxed string slice without checking diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 96d719c528c10..312da20357449 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -490,77 +490,199 @@ impl AsciiExt for [u8] { } } -macro_rules! impl_by_delegating { - ($ty:ty, $owned:ty) => { - #[stable(feature = "rust1", since = "1.0.0")] - impl AsciiExt for $ty { - type Owned = $owned; +macro_rules! delegating_ascii_methods { + () => { + #[inline] + fn is_ascii(&self) -> bool { self.is_ascii() } - #[inline] - fn is_ascii(&self) -> bool { self.is_ascii() } + #[inline] + fn to_ascii_uppercase(&self) -> Self::Owned { self.to_ascii_uppercase() } - #[inline] - fn to_ascii_uppercase(&self) -> Self::Owned { self.to_ascii_uppercase() } + #[inline] + fn to_ascii_lowercase(&self) -> Self::Owned { self.to_ascii_lowercase() } - #[inline] - fn to_ascii_lowercase(&self) -> Self::Owned { self.to_ascii_lowercase() } + #[inline] + fn eq_ignore_ascii_case(&self, o: &Self) -> bool { self.eq_ignore_ascii_case(o) } - #[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_uppercase(&mut self) { self.make_ascii_uppercase(); } - - #[inline] - fn make_ascii_lowercase(&mut self) { self.make_ascii_lowercase(); } + #[inline] + fn make_ascii_lowercase(&mut self) { self.make_ascii_lowercase(); } + } +} - #[inline] - fn is_ascii_alphabetic(&self) -> bool { self.is_ascii_alphabetic() } +macro_rules! delegating_ascii_ctype_methods { + () => { + #[inline] + fn is_ascii_alphabetic(&self) -> bool { self.is_ascii_alphabetic() } - #[inline] - fn is_ascii_uppercase(&self) -> bool { self.is_ascii_uppercase() } + #[inline] + fn is_ascii_uppercase(&self) -> bool { self.is_ascii_uppercase() } - #[inline] - fn is_ascii_lowercase(&self) -> bool { self.is_ascii_lowercase() } + #[inline] + fn is_ascii_lowercase(&self) -> bool { self.is_ascii_lowercase() } - #[inline] - fn is_ascii_alphanumeric(&self) -> bool { self.is_ascii_alphanumeric() } + #[inline] + fn is_ascii_alphanumeric(&self) -> bool { self.is_ascii_alphanumeric() } - #[inline] - fn is_ascii_digit(&self) -> bool { self.is_ascii_digit() } + #[inline] + fn is_ascii_digit(&self) -> bool { self.is_ascii_digit() } - #[inline] - fn is_ascii_hexdigit(&self) -> bool { self.is_ascii_hexdigit() } + #[inline] + fn is_ascii_hexdigit(&self) -> bool { self.is_ascii_hexdigit() } - #[inline] - fn is_ascii_punctuation(&self) -> bool { self.is_ascii_punctuation() } + #[inline] + fn is_ascii_punctuation(&self) -> bool { self.is_ascii_punctuation() } - #[inline] - fn is_ascii_graphic(&self) -> bool { self.is_ascii_graphic() } + #[inline] + fn is_ascii_graphic(&self) -> bool { self.is_ascii_graphic() } - #[inline] - fn is_ascii_whitespace(&self) -> bool { self.is_ascii_whitespace() } + #[inline] + fn is_ascii_whitespace(&self) -> bool { self.is_ascii_whitespace() } - #[inline] - fn is_ascii_control(&self) -> bool { self.is_ascii_control() } - } + #[inline] + fn is_ascii_control(&self) -> bool { self.is_ascii_control() } } } -impl_by_delegating!(u8, u8); -impl_by_delegating!(char, char); +#[stable(feature = "rust1", since = "1.0.0")] +impl AsciiExt for u8 { + type Owned = u8; + + delegating_ascii_methods!(); + delegating_ascii_ctype_methods!(); +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl AsciiExt for char { + type Owned = char; + + delegating_ascii_methods!(); + 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))] -impl_by_delegating!([u8], Vec); +#[stable(feature = "rust1", since = "1.0.0")] +impl AsciiExt for [u8] { + type Owned = Vec; + + delegating_ascii_methods!(); + + #[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()) + } +} // 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))] -impl_by_delegating!(str, String); +#[stable(feature = "rust1", since = "1.0.0")] +impl AsciiExt for str { + type Owned = String; + + delegating_ascii_methods!(); + + #[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()) + } +} /// An iterator over the escaped version of a byte. /// @@ -684,6 +806,7 @@ mod tests { //! Note that most of these tests are not testing `AsciiExt` methods, but //! test inherent ascii methods of char, u8, str and [u8]. `AsciiExt` is //! just using those methods, though. + use super::AsciiExt; use char::from_u32; #[test] From 03370177cac86fa2bce96abd054bf610f7fffeba Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 18 Nov 2017 13:47:36 +0100 Subject: [PATCH 2/3] Stabilize `ascii_ctype` methods for `u8` and `char` The feature of those methods was renamed to "ascii_ctype_on_intrinsics". --- src/libcore/num/mod.rs | 20 ++++++++++---------- src/libstd_unicode/char.rs | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 1230066e2b33b..408e0a0249e27 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2420,7 +2420,7 @@ impl u8 { /// assert!(!lf.is_ascii_alphabetic()); /// assert!(!esc.is_ascii_alphabetic()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { if *self >= 0x80 { return false; } @@ -2458,7 +2458,7 @@ impl u8 { /// assert!(!lf.is_ascii_uppercase()); /// assert!(!esc.is_ascii_uppercase()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { if *self >= 0x80 { return false } @@ -2496,7 +2496,7 @@ impl u8 { /// assert!(!lf.is_ascii_lowercase()); /// assert!(!esc.is_ascii_lowercase()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { if *self >= 0x80 { return false } @@ -2537,7 +2537,7 @@ impl u8 { /// assert!(!lf.is_ascii_alphanumeric()); /// assert!(!esc.is_ascii_alphanumeric()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { if *self >= 0x80 { return false } @@ -2575,7 +2575,7 @@ impl u8 { /// assert!(!lf.is_ascii_digit()); /// assert!(!esc.is_ascii_digit()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { if *self >= 0x80 { return false } @@ -2616,7 +2616,7 @@ impl u8 { /// assert!(!lf.is_ascii_hexdigit()); /// assert!(!esc.is_ascii_hexdigit()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { if *self >= 0x80 { return false } @@ -2658,7 +2658,7 @@ impl u8 { /// assert!(!lf.is_ascii_punctuation()); /// assert!(!esc.is_ascii_punctuation()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { if *self >= 0x80 { return false } @@ -2696,7 +2696,7 @@ impl u8 { /// assert!(!lf.is_ascii_graphic()); /// assert!(!esc.is_ascii_graphic()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { if *self >= 0x80 { return false; } @@ -2751,7 +2751,7 @@ impl u8 { /// assert!(lf.is_ascii_whitespace()); /// assert!(!esc.is_ascii_whitespace()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { if *self >= 0x80 { return false; } @@ -2791,7 +2791,7 @@ impl u8 { /// assert!(lf.is_ascii_control()); /// assert!(esc.is_ascii_control()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_control(&self) -> bool { if *self >= 0x80 { return false; } diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs index e20937c6c7bdb..5e7f7062ef77b 100644 --- a/src/libstd_unicode/char.rs +++ b/src/libstd_unicode/char.rs @@ -1106,7 +1106,7 @@ impl char { /// assert!(!lf.is_ascii_alphabetic()); /// assert!(!esc.is_ascii_alphabetic()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_alphabetic() @@ -1140,7 +1140,7 @@ impl char { /// assert!(!lf.is_ascii_uppercase()); /// assert!(!esc.is_ascii_uppercase()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_uppercase() @@ -1174,7 +1174,7 @@ impl char { /// assert!(!lf.is_ascii_lowercase()); /// assert!(!esc.is_ascii_lowercase()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_lowercase() @@ -1211,7 +1211,7 @@ impl char { /// assert!(!lf.is_ascii_alphanumeric()); /// assert!(!esc.is_ascii_alphanumeric()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_alphanumeric() @@ -1245,7 +1245,7 @@ impl char { /// assert!(!lf.is_ascii_digit()); /// assert!(!esc.is_ascii_digit()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_digit() @@ -1282,7 +1282,7 @@ impl char { /// assert!(!lf.is_ascii_hexdigit()); /// assert!(!esc.is_ascii_hexdigit()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_hexdigit() @@ -1320,7 +1320,7 @@ impl char { /// assert!(!lf.is_ascii_punctuation()); /// assert!(!esc.is_ascii_punctuation()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_punctuation() @@ -1354,7 +1354,7 @@ impl char { /// assert!(!lf.is_ascii_graphic()); /// assert!(!esc.is_ascii_graphic()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_graphic() @@ -1405,7 +1405,7 @@ impl char { /// assert!(lf.is_ascii_whitespace()); /// assert!(!esc.is_ascii_whitespace()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_whitespace() @@ -1441,7 +1441,7 @@ impl char { /// assert!(lf.is_ascii_control()); /// assert!(esc.is_ascii_control()); /// ``` - #[unstable(feature = "ascii_ctype", issue = "39658")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] #[inline] pub fn is_ascii_control(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_control() From c5aad96739228e8e05b597b32ee7126c843b7228 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Tue, 28 Nov 2017 08:50:40 +0100 Subject: [PATCH 3/3] Change `since` attribute from ctype methods from 1.23 to 1.24 The changes didn't land in time for 1.23 and stabilizations won't be backported to beta. --- src/libcore/num/mod.rs | 20 ++++++++++---------- src/libstd_unicode/char.rs | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 408e0a0249e27..bfb7a2ecd3099 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -2420,7 +2420,7 @@ impl u8 { /// assert!(!lf.is_ascii_alphabetic()); /// assert!(!esc.is_ascii_alphabetic()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { if *self >= 0x80 { return false; } @@ -2458,7 +2458,7 @@ impl u8 { /// assert!(!lf.is_ascii_uppercase()); /// assert!(!esc.is_ascii_uppercase()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { if *self >= 0x80 { return false } @@ -2496,7 +2496,7 @@ impl u8 { /// assert!(!lf.is_ascii_lowercase()); /// assert!(!esc.is_ascii_lowercase()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { if *self >= 0x80 { return false } @@ -2537,7 +2537,7 @@ impl u8 { /// assert!(!lf.is_ascii_alphanumeric()); /// assert!(!esc.is_ascii_alphanumeric()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { if *self >= 0x80 { return false } @@ -2575,7 +2575,7 @@ impl u8 { /// assert!(!lf.is_ascii_digit()); /// assert!(!esc.is_ascii_digit()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { if *self >= 0x80 { return false } @@ -2616,7 +2616,7 @@ impl u8 { /// assert!(!lf.is_ascii_hexdigit()); /// assert!(!esc.is_ascii_hexdigit()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { if *self >= 0x80 { return false } @@ -2658,7 +2658,7 @@ impl u8 { /// assert!(!lf.is_ascii_punctuation()); /// assert!(!esc.is_ascii_punctuation()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { if *self >= 0x80 { return false } @@ -2696,7 +2696,7 @@ impl u8 { /// assert!(!lf.is_ascii_graphic()); /// assert!(!esc.is_ascii_graphic()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { if *self >= 0x80 { return false; } @@ -2751,7 +2751,7 @@ impl u8 { /// assert!(lf.is_ascii_whitespace()); /// assert!(!esc.is_ascii_whitespace()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { if *self >= 0x80 { return false; } @@ -2791,7 +2791,7 @@ impl u8 { /// assert!(lf.is_ascii_control()); /// assert!(esc.is_ascii_control()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_control(&self) -> bool { if *self >= 0x80 { return false; } diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs index 5e7f7062ef77b..abada1bc3206c 100644 --- a/src/libstd_unicode/char.rs +++ b/src/libstd_unicode/char.rs @@ -1106,7 +1106,7 @@ impl char { /// assert!(!lf.is_ascii_alphabetic()); /// assert!(!esc.is_ascii_alphabetic()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphabetic(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_alphabetic() @@ -1140,7 +1140,7 @@ impl char { /// assert!(!lf.is_ascii_uppercase()); /// assert!(!esc.is_ascii_uppercase()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_uppercase(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_uppercase() @@ -1174,7 +1174,7 @@ impl char { /// assert!(!lf.is_ascii_lowercase()); /// assert!(!esc.is_ascii_lowercase()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_lowercase(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_lowercase() @@ -1211,7 +1211,7 @@ impl char { /// assert!(!lf.is_ascii_alphanumeric()); /// assert!(!esc.is_ascii_alphanumeric()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_alphanumeric(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_alphanumeric() @@ -1245,7 +1245,7 @@ impl char { /// assert!(!lf.is_ascii_digit()); /// assert!(!esc.is_ascii_digit()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_digit(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_digit() @@ -1282,7 +1282,7 @@ impl char { /// assert!(!lf.is_ascii_hexdigit()); /// assert!(!esc.is_ascii_hexdigit()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_hexdigit(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_hexdigit() @@ -1320,7 +1320,7 @@ impl char { /// assert!(!lf.is_ascii_punctuation()); /// assert!(!esc.is_ascii_punctuation()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_punctuation(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_punctuation() @@ -1354,7 +1354,7 @@ impl char { /// assert!(!lf.is_ascii_graphic()); /// assert!(!esc.is_ascii_graphic()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_graphic(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_graphic() @@ -1405,7 +1405,7 @@ impl char { /// assert!(lf.is_ascii_whitespace()); /// assert!(!esc.is_ascii_whitespace()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_whitespace(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_whitespace() @@ -1441,7 +1441,7 @@ impl char { /// assert!(lf.is_ascii_control()); /// assert!(esc.is_ascii_control()); /// ``` - #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.23.0")] + #[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")] #[inline] pub fn is_ascii_control(&self) -> bool { self.is_ascii() && (*self as u8).is_ascii_control()