Stabilise inherent_ascii_escape (FCP in #77174)
This commit is contained in:
parent
9efe61df7f
commit
de6e973176
5 changed files with 11 additions and 14 deletions
|
@ -112,7 +112,6 @@
|
||||||
#![feature(extend_one)]
|
#![feature(extend_one)]
|
||||||
#![feature(fmt_internals)]
|
#![feature(fmt_internals)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(inherent_ascii_escape)]
|
|
||||||
#![feature(inplace_iteration)]
|
#![feature(inplace_iteration)]
|
||||||
#![feature(iter_advance_by)]
|
#![feature(iter_advance_by)]
|
||||||
#![feature(layout_for_ptr)]
|
#![feature(layout_for_ptr)]
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub use core::slice::ArrayChunks;
|
||||||
pub use core::slice::ArrayChunksMut;
|
pub use core::slice::ArrayChunksMut;
|
||||||
#[unstable(feature = "array_windows", issue = "75027")]
|
#[unstable(feature = "array_windows", issue = "75027")]
|
||||||
pub use core::slice::ArrayWindows;
|
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;
|
pub use core::slice::EscapeAscii;
|
||||||
#[stable(feature = "slice_get_slice", since = "1.28.0")]
|
#[stable(feature = "slice_get_slice", since = "1.28.0")]
|
||||||
pub use core::slice::SliceIndex;
|
pub use core::slice::SliceIndex;
|
||||||
|
|
|
@ -791,7 +791,6 @@ impl u8 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(inherent_ascii_escape)]
|
|
||||||
///
|
///
|
||||||
/// assert_eq!("0", b'0'.escape_ascii().to_string());
|
/// assert_eq!("0", b'0'.escape_ascii().to_string());
|
||||||
/// assert_eq!("\\t", b'\t'.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, \
|
#[must_use = "this returns the escaped byte as an iterator, \
|
||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[unstable(feature = "inherent_ascii_escape", issue = "77174")]
|
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn escape_ascii(self) -> ascii::EscapeDefault {
|
pub fn escape_ascii(self) -> ascii::EscapeDefault {
|
||||||
ascii::escape_default(self)
|
ascii::escape_default(self)
|
||||||
|
|
|
@ -68,7 +68,6 @@ impl [u8] {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(inherent_ascii_escape)]
|
|
||||||
///
|
///
|
||||||
/// let s = b"0\t\r\n'\"\\\x9d";
|
/// let s = b"0\t\r\n'\"\\\x9d";
|
||||||
/// let escaped = s.escape_ascii().to_string();
|
/// let escaped = s.escape_ascii().to_string();
|
||||||
|
@ -76,7 +75,7 @@ impl [u8] {
|
||||||
/// ```
|
/// ```
|
||||||
#[must_use = "this returns the escaped bytes as an iterator, \
|
#[must_use = "this returns the escaped bytes as an iterator, \
|
||||||
without modifying the original"]
|
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<'_> {
|
pub fn escape_ascii(&self) -> EscapeAscii<'_> {
|
||||||
EscapeAscii { inner: self.iter().flat_map(EscapeByte) }
|
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
|
/// This `struct` is created by the [`slice::escape_ascii`] method. See its
|
||||||
/// documentation for more information.
|
/// documentation for more information.
|
||||||
#[unstable(feature = "inherent_ascii_escape", issue = "77174")]
|
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EscapeAscii<'a> {
|
pub struct EscapeAscii<'a> {
|
||||||
inner: iter::FlatMap<super::Iter<'a, u8>, ascii::EscapeDefault, EscapeByte>,
|
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> {
|
impl<'a> iter::Iterator for EscapeAscii<'a> {
|
||||||
type Item = u8;
|
type Item = u8;
|
||||||
#[inline]
|
#[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> {
|
impl<'a> iter::DoubleEndedIterator for EscapeAscii<'a> {
|
||||||
fn next_back(&mut self) -> Option<u8> {
|
fn next_back(&mut self) -> Option<u8> {
|
||||||
self.inner.next_back()
|
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> {}
|
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> {}
|
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> {
|
impl<'a> fmt::Display for EscapeAscii<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.clone().try_for_each(|b| f.write_char(b as char))
|
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> {
|
impl<'a> fmt::Debug for EscapeAscii<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("EscapeAscii").finish_non_exhaustive()
|
f.debug_struct("EscapeAscii").finish_non_exhaustive()
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub use index::SliceIndex;
|
||||||
#[unstable(feature = "slice_range", issue = "76393")]
|
#[unstable(feature = "slice_range", issue = "76393")]
|
||||||
pub use index::range;
|
pub use index::range;
|
||||||
|
|
||||||
#[unstable(feature = "inherent_ascii_escape", issue = "77174")]
|
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
|
||||||
pub use ascii::EscapeAscii;
|
pub use ascii::EscapeAscii;
|
||||||
|
|
||||||
/// Calculates the direction and split point of a one-sided range.
|
/// Calculates the direction and split point of a one-sided range.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue