Rollup merge of #93886 - clarfonthey:stable_ascii_escape, r=Mark-Simulacrum

Stabilise inherent_ascii_escape (FCP in #77174)

Implements #77174, which completed its FCP.

This does *not* deprecate any existing methods or structs, as that is tracked in #93887. That stated, people should prefer using `u8::escape_ascii` to `std::ascii::escape_default`.
This commit is contained in:
Matthias Krüger 2022-02-13 06:44:17 +01:00 committed by GitHub
commit 5699f683a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 16 deletions

View File

@ -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)]

View File

@ -108,7 +108,7 @@
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;

View File

@ -791,7 +791,6 @@ pub const fn is_ascii_control(&self) -> bool {
/// # Examples
///
/// ```
/// #![feature(inherent_ascii_escape)]
///
/// assert_eq!("0", b'0'.escape_ascii().to_string());
/// assert_eq!("\\t", b'\t'.escape_ascii().to_string());
@ -804,10 +803,10 @@ pub const fn is_ascii_control(&self) -> bool {
/// ```
#[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)
pub fn escape_ascii(self) -> ascii::EscapeDefault {
ascii::escape_default(self)
}
pub(crate) fn is_utf8_char_boundary(self) -> bool {

View File

@ -68,7 +68,6 @@ pub fn make_ascii_lowercase(&mut self) {
/// # Examples
///
/// ```
/// #![feature(inherent_ascii_escape)]
///
/// let s = b"0\t\r\n'\"\\\x9d";
/// let escaped = s.escape_ascii().to_string();
@ -76,7 +75,7 @@ pub fn make_ascii_lowercase(&mut self) {
/// ```
#[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 @@ struct EscapeByte impl Fn = |byte: &u8| -> ascii::EscapeDefault {
///
/// 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<super::Iter<'a, u8>, 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 @@ fn last(mut self) -> Option<u8> {
}
}
#[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<u8> {
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()

View File

@ -81,7 +81,7 @@
#[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.