Auto merge of #46411 - rillian:str_ascii, r=kennytm

Mark ascii methods on primitive types stable in 1.23.0 not 1.21.0.

The ascii_methods_on_intrinsics feature stabilization
didn't land in time for 1.21.0. Update the annotation
so the documentation is correct about when these
methods became available.
This commit is contained in:
bors 2017-12-12 03:30:43 +00:00
commit 3a0b652846
4 changed files with 24 additions and 24 deletions

View file

@ -1630,7 +1630,7 @@ impl<T> [T] {
#[cfg(not(test))] #[cfg(not(test))]
impl [u8] { impl [u8] {
/// Checks if all bytes in this slice are within the ASCII range. /// Checks if all bytes in this slice are within the ASCII range.
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn is_ascii(&self) -> bool { pub fn is_ascii(&self) -> bool {
self.iter().all(|b| b.is_ascii()) self.iter().all(|b| b.is_ascii())
@ -1645,7 +1645,7 @@ impl [u8] {
/// To uppercase the value in-place, use [`make_ascii_uppercase`]. /// To uppercase the value in-place, use [`make_ascii_uppercase`].
/// ///
/// [`make_ascii_uppercase`]: #method.make_ascii_uppercase /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_uppercase(&self) -> Vec<u8> { pub fn to_ascii_uppercase(&self) -> Vec<u8> {
let mut me = self.to_vec(); let mut me = self.to_vec();
@ -1662,7 +1662,7 @@ impl [u8] {
/// To lowercase the value in-place, use [`make_ascii_lowercase`]. /// To lowercase the value in-place, use [`make_ascii_lowercase`].
/// ///
/// [`make_ascii_lowercase`]: #method.make_ascii_lowercase /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_lowercase(&self) -> Vec<u8> { pub fn to_ascii_lowercase(&self) -> Vec<u8> {
let mut me = self.to_vec(); let mut me = self.to_vec();
@ -1674,7 +1674,7 @@ impl [u8] {
/// ///
/// Same as `to_ascii_lowercase(a) == to_ascii_lowercase(b)`, /// Same as `to_ascii_lowercase(a) == to_ascii_lowercase(b)`,
/// but without allocating and copying temporaries. /// but without allocating and copying temporaries.
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool { pub fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool {
self.len() == other.len() && self.len() == other.len() &&
@ -1692,7 +1692,7 @@ impl [u8] {
/// [`to_ascii_uppercase`]. /// [`to_ascii_uppercase`].
/// ///
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_uppercase(&mut self) { pub fn make_ascii_uppercase(&mut self) {
for byte in self { for byte in self {
@ -1709,7 +1709,7 @@ impl [u8] {
/// [`to_ascii_lowercase`]. /// [`to_ascii_lowercase`].
/// ///
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_lowercase(&mut self) { pub fn make_ascii_lowercase(&mut self) {
for byte in self { for byte in self {

View file

@ -2078,7 +2078,7 @@ impl str {
/// assert!(ascii.is_ascii()); /// assert!(ascii.is_ascii());
/// assert!(!non_ascii.is_ascii()); /// assert!(!non_ascii.is_ascii());
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn is_ascii(&self) -> bool { pub fn is_ascii(&self) -> bool {
// We can treat each byte as character here: all multibyte characters // We can treat each byte as character here: all multibyte characters
@ -2108,7 +2108,7 @@ impl str {
/// ///
/// [`make_ascii_uppercase`]: #method.make_ascii_uppercase /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
/// [`to_uppercase`]: #method.to_uppercase /// [`to_uppercase`]: #method.to_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_uppercase(&self) -> String { pub fn to_ascii_uppercase(&self) -> String {
let mut bytes = self.as_bytes().to_vec(); let mut bytes = self.as_bytes().to_vec();
@ -2138,7 +2138,7 @@ impl str {
/// ///
/// [`make_ascii_lowercase`]: #method.make_ascii_lowercase /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
/// [`to_lowercase`]: #method.to_lowercase /// [`to_lowercase`]: #method.to_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_lowercase(&self) -> String { pub fn to_ascii_lowercase(&self) -> String {
let mut bytes = self.as_bytes().to_vec(); let mut bytes = self.as_bytes().to_vec();
@ -2159,7 +2159,7 @@ impl str {
/// assert!("Ferrös".eq_ignore_ascii_case("FERRöS")); /// assert!("Ferrös".eq_ignore_ascii_case("FERRöS"));
/// assert!(!"Ferrös".eq_ignore_ascii_case("FERRÖS")); /// assert!(!"Ferrös".eq_ignore_ascii_case("FERRÖS"));
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn eq_ignore_ascii_case(&self, other: &str) -> bool { pub fn eq_ignore_ascii_case(&self, other: &str) -> bool {
self.as_bytes().eq_ignore_ascii_case(other.as_bytes()) self.as_bytes().eq_ignore_ascii_case(other.as_bytes())
@ -2174,7 +2174,7 @@ impl str {
/// [`to_ascii_uppercase`]. /// [`to_ascii_uppercase`].
/// ///
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
pub fn make_ascii_uppercase(&mut self) { pub fn make_ascii_uppercase(&mut self) {
let me = unsafe { self.as_bytes_mut() }; let me = unsafe { self.as_bytes_mut() };
me.make_ascii_uppercase() me.make_ascii_uppercase()
@ -2189,7 +2189,7 @@ impl str {
/// [`to_ascii_lowercase`]. /// [`to_ascii_lowercase`].
/// ///
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
pub fn make_ascii_lowercase(&mut self) { pub fn make_ascii_lowercase(&mut self) {
let me = unsafe { self.as_bytes_mut() }; let me = unsafe { self.as_bytes_mut() };
me.make_ascii_lowercase() me.make_ascii_lowercase()

View file

@ -2286,7 +2286,7 @@ impl u8 {
/// assert!(ascii.is_ascii()); /// assert!(ascii.is_ascii());
/// assert!(!non_ascii.is_ascii()); /// assert!(!non_ascii.is_ascii());
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn is_ascii(&self) -> bool { pub fn is_ascii(&self) -> bool {
*self & 128 == 0 *self & 128 == 0
@ -2308,7 +2308,7 @@ impl u8 {
/// ``` /// ```
/// ///
/// [`make_ascii_uppercase`]: #method.make_ascii_uppercase /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_uppercase(&self) -> u8 { pub fn to_ascii_uppercase(&self) -> u8 {
ASCII_UPPERCASE_MAP[*self as usize] ASCII_UPPERCASE_MAP[*self as usize]
@ -2330,7 +2330,7 @@ impl u8 {
/// ``` /// ```
/// ///
/// [`make_ascii_lowercase`]: #method.make_ascii_lowercase /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_lowercase(&self) -> u8 { pub fn to_ascii_lowercase(&self) -> u8 {
ASCII_LOWERCASE_MAP[*self as usize] ASCII_LOWERCASE_MAP[*self as usize]
@ -2348,7 +2348,7 @@ impl u8 {
/// ///
/// assert!(lowercase_a.eq_ignore_ascii_case(&uppercase_a)); /// assert!(lowercase_a.eq_ignore_ascii_case(&uppercase_a));
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn eq_ignore_ascii_case(&self, other: &u8) -> bool { pub fn eq_ignore_ascii_case(&self, other: &u8) -> bool {
self.to_ascii_lowercase() == other.to_ascii_lowercase() self.to_ascii_lowercase() == other.to_ascii_lowercase()
@ -2373,7 +2373,7 @@ impl u8 {
/// ``` /// ```
/// ///
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_uppercase(&mut self) { pub fn make_ascii_uppercase(&mut self) {
*self = self.to_ascii_uppercase(); *self = self.to_ascii_uppercase();
@ -2398,7 +2398,7 @@ impl u8 {
/// ``` /// ```
/// ///
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_lowercase(&mut self) { pub fn make_ascii_lowercase(&mut self) {
*self = self.to_ascii_lowercase(); *self = self.to_ascii_lowercase();

View file

@ -938,7 +938,7 @@ impl char {
/// assert!(ascii.is_ascii()); /// assert!(ascii.is_ascii());
/// assert!(!non_ascii.is_ascii()); /// assert!(!non_ascii.is_ascii());
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn is_ascii(&self) -> bool { pub fn is_ascii(&self) -> bool {
*self as u32 <= 0x7F *self as u32 <= 0x7F
@ -966,7 +966,7 @@ impl char {
/// ///
/// [`make_ascii_uppercase`]: #method.make_ascii_uppercase /// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
/// [`to_uppercase`]: #method.to_uppercase /// [`to_uppercase`]: #method.to_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_uppercase(&self) -> char { pub fn to_ascii_uppercase(&self) -> char {
if self.is_ascii() { if self.is_ascii() {
@ -998,7 +998,7 @@ impl char {
/// ///
/// [`make_ascii_lowercase`]: #method.make_ascii_lowercase /// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
/// [`to_lowercase`]: #method.to_lowercase /// [`to_lowercase`]: #method.to_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn to_ascii_lowercase(&self) -> char { pub fn to_ascii_lowercase(&self) -> char {
if self.is_ascii() { if self.is_ascii() {
@ -1023,7 +1023,7 @@ impl char {
/// assert!(upper_a.eq_ignore_ascii_case(&upper_a)); /// assert!(upper_a.eq_ignore_ascii_case(&upper_a));
/// assert!(!upper_a.eq_ignore_ascii_case(&lower_z)); /// assert!(!upper_a.eq_ignore_ascii_case(&lower_z));
/// ``` /// ```
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn eq_ignore_ascii_case(&self, other: &char) -> bool { pub fn eq_ignore_ascii_case(&self, other: &char) -> bool {
self.to_ascii_lowercase() == other.to_ascii_lowercase() self.to_ascii_lowercase() == other.to_ascii_lowercase()
@ -1048,7 +1048,7 @@ impl char {
/// ``` /// ```
/// ///
/// [`to_ascii_uppercase`]: #method.to_ascii_uppercase /// [`to_ascii_uppercase`]: #method.to_ascii_uppercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_uppercase(&mut self) { pub fn make_ascii_uppercase(&mut self) {
*self = self.to_ascii_uppercase(); *self = self.to_ascii_uppercase();
@ -1073,7 +1073,7 @@ impl char {
/// ``` /// ```
/// ///
/// [`to_ascii_lowercase`]: #method.to_ascii_lowercase /// [`to_ascii_lowercase`]: #method.to_ascii_lowercase
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.21.0")] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
#[inline] #[inline]
pub fn make_ascii_lowercase(&mut self) { pub fn make_ascii_lowercase(&mut self) {
*self = self.to_ascii_lowercase(); *self = self.to_ascii_lowercase();