From 9efe61df7f609de8d90fb7f40b29ea6fe72ff205 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sat, 12 Feb 2022 13:15:10 -0500 Subject: [PATCH 1/2] Fix signature of u8::escape_ascii --- library/core/src/num/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 864a253299f..40bd706da8c 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -806,8 +806,8 @@ impl u8 { without modifying the original"] #[unstable(feature = "inherent_ascii_escape", issue = "77174")] #[inline] - pub fn escape_ascii(&self) -> ascii::EscapeDefault { - ascii::escape_default(*self) + pub fn escape_ascii(self) -> ascii::EscapeDefault { + ascii::escape_default(self) } pub(crate) fn is_utf8_char_boundary(self) -> bool { From de6e9731764af14b27b6158834454344da49c37d Mon Sep 17 00:00:00 2001 From: ltdk Date: Thu, 10 Feb 2022 21:09:05 -0500 Subject: [PATCH 2/2] Stabilise inherent_ascii_escape (FCP in #77174) --- library/alloc/src/lib.rs | 1 - library/alloc/src/slice.rs | 2 +- library/core/src/num/mod.rs | 3 +-- library/core/src/slice/ascii.rs | 17 ++++++++--------- library/core/src/slice/mod.rs | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index ab9f0b9d737..ce75859f963 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -112,7 +112,6 @@ #![feature(extend_one)] #![feature(fmt_internals)] #![feature(fn_traits)] -#![feature(inherent_ascii_escape)] #![feature(inplace_iteration)] #![feature(iter_advance_by)] #![feature(layout_for_ptr)] diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs index a5c4140e313..f0397d08f95 100644 --- a/library/alloc/src/slice.rs +++ b/library/alloc/src/slice.rs @@ -108,7 +108,7 @@ pub use core::slice::ArrayChunks; pub use core::slice::ArrayChunksMut; #[unstable(feature = "array_windows", issue = "75027")] pub use core::slice::ArrayWindows; -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub use core::slice::EscapeAscii; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 40bd706da8c..72105888f94 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -791,7 +791,6 @@ impl u8 { /// # Examples /// /// ``` - /// #![feature(inherent_ascii_escape)] /// /// assert_eq!("0", b'0'.escape_ascii().to_string()); /// assert_eq!("\\t", b'\t'.escape_ascii().to_string()); @@ -804,7 +803,7 @@ impl u8 { /// ``` #[must_use = "this returns the escaped byte as an iterator, \ without modifying the original"] - #[unstable(feature = "inherent_ascii_escape", issue = "77174")] + #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] #[inline] pub fn escape_ascii(self) -> ascii::EscapeDefault { ascii::escape_default(self) diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index 080256f493f..304ba7ee554 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -68,7 +68,6 @@ impl [u8] { /// # Examples /// /// ``` - /// #![feature(inherent_ascii_escape)] /// /// let s = b"0\t\r\n'\"\\\x9d"; /// let escaped = s.escape_ascii().to_string(); @@ -76,7 +75,7 @@ impl [u8] { /// ``` #[must_use = "this returns the escaped bytes as an iterator, \ without modifying the original"] - #[unstable(feature = "inherent_ascii_escape", issue = "77174")] + #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub fn escape_ascii(&self) -> EscapeAscii<'_> { EscapeAscii { inner: self.iter().flat_map(EscapeByte) } } @@ -93,13 +92,13 @@ impl_fn_for_zst! { /// /// This `struct` is created by the [`slice::escape_ascii`] method. See its /// documentation for more information. -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] #[derive(Clone)] pub struct EscapeAscii<'a> { inner: iter::FlatMap, ascii::EscapeDefault, EscapeByte>, } -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> iter::Iterator for EscapeAscii<'a> { type Item = u8; #[inline] @@ -131,23 +130,23 @@ impl<'a> iter::Iterator for EscapeAscii<'a> { } } -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> iter::DoubleEndedIterator for EscapeAscii<'a> { fn next_back(&mut self) -> Option { self.inner.next_back() } } -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> iter::ExactSizeIterator for EscapeAscii<'a> {} -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> iter::FusedIterator for EscapeAscii<'a> {} -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> fmt::Display for EscapeAscii<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.clone().try_for_each(|b| f.write_char(b as char)) } } -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] impl<'a> fmt::Debug for EscapeAscii<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("EscapeAscii").finish_non_exhaustive() diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 4e22c1d8c6d..cd38c3a7547 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -81,7 +81,7 @@ pub use index::SliceIndex; #[unstable(feature = "slice_range", issue = "76393")] pub use index::range; -#[unstable(feature = "inherent_ascii_escape", issue = "77174")] +#[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub use ascii::EscapeAscii; /// Calculates the direction and split point of a one-sided range.