Skip to content

Commit

Permalink
Stabilize str::escape_* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Feb 12, 2019
1 parent 7a07780 commit 55216f8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
20 changes: 7 additions & 13 deletions src/liballoc/str.rs
Expand Up @@ -452,9 +452,7 @@ impl str {
/// escaped.
///
/// [`char::escape_debug`]: primitive.char.html#method.escape_debug
#[unstable(feature = "str_escape",
reason = "return type may change to be an iterator",
issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
pub fn escape_debug(&self) -> EscapeDebug {
let mut chars = self.chars();
EscapeDebug {
Expand All @@ -469,19 +467,15 @@ impl str {
/// Escapes each char in `s` with [`char::escape_default`].
///
/// [`char::escape_default`]: primitive.char.html#method.escape_default
#[unstable(feature = "str_escape",
reason = "return type may change to be an iterator",
issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
pub fn escape_default(&self) -> EscapeDefault {
EscapeDefault { inner: self.chars().flat_map(CharEscapeDefault) }
}

/// Escapes each char in `s` with [`char::escape_unicode`].
///
/// [`char::escape_unicode`]: primitive.char.html#method.escape_unicode
#[unstable(feature = "str_escape",
reason = "return type may change to be an iterator",
issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
pub fn escape_unicode(&self) -> EscapeUnicode {
EscapeUnicode { inner: self.chars().flat_map(CharEscapeUnicode) }
}
Expand Down Expand Up @@ -639,20 +633,20 @@ macro_rules! escape_types {
inner: $Inner: ty,
}
)+) => {$(
#[unstable(feature = "str_escape", issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
#[derive(Clone, Debug)]
pub struct $Name<'a> {
inner: $Inner,
}

#[unstable(feature = "str_escape", issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
impl<'a> fmt::Display for $Name<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.clone().try_for_each(|c| f.write_char(c))
}
}

#[unstable(feature = "str_escape", issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
impl<'a> Iterator for $Name<'a> {
type Item = char;

Expand All @@ -677,7 +671,7 @@ macro_rules! escape_types {
}
}

#[unstable(feature = "str_escape", issue = "27791")]
#[stable(feature = "str_escape", since = "1.34.0")]
impl<'a> FusedIterator for $Name<'a> {}
)+}
}
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Expand Up @@ -5,7 +5,6 @@
#![feature(pattern)]
#![feature(repeat_generic_slice)]
#![feature(slice_sort_by_cached_key)]
#![feature(str_escape)]
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(vecdeque_rotate)]
Expand Down
1 change: 0 additions & 1 deletion src/libgraphviz/lib.rs
Expand Up @@ -277,7 +277,6 @@
#![deny(rust_2018_idioms)]

#![feature(nll)]
#![feature(str_escape)]

use LabelText::*;

Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/lib.rs
Expand Up @@ -15,7 +15,6 @@
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
#![feature(str_escape)]
#![feature(step_trait)]
#![feature(try_trait)]
#![feature(unicode_internals)]
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax_ext/lib.rs
Expand Up @@ -10,7 +10,6 @@
#![feature(proc_macro_span)]
#![feature(decl_macro)]
#![feature(nll)]
#![feature(str_escape)]
#![feature(rustc_diagnostic_macros)]

#![recursion_limit="256"]
Expand Down
Expand Up @@ -2,9 +2,6 @@
// pretty-expanded FIXME #23616

#![allow(warnings)]
#![feature(iter_empty)]
#![feature(iter_once)]
#![feature(str_escape)]

use std::iter::{empty, once, repeat};

Expand Down

0 comments on commit 55216f8

Please sign in to comment.