diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2016-07-26 01:39:54 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2016-07-26 15:15:00 +0200 |
| commit | 68efea08fa1cf800b3b76683992ec77a89323d53 (patch) | |
| tree | f9c7cee686d99efacdf80cbbaf477bd6ff19f12f /src/libcollections | |
| parent | 0685900fbd1ea1f6be5c3454dcde753ac3484c01 (diff) | |
| download | rust-68efea08fa1cf800b3b76683992ec77a89323d53.tar.gz rust-68efea08fa1cf800b3b76683992ec77a89323d53.zip | |
Restore `char::escape_default` and add `char::escape` instead
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/lib.rs | 1 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index f027d074cb6..333219bc5e5 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -33,6 +33,7 @@ #![feature(allow_internal_unstable)] #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(char_escape)] #![feature(core_intrinsics)] #![feature(dropck_parametricity)] #![feature(fmt_internals)] diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 55308a46f0a..a63ea9d3ec7 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1697,6 +1697,14 @@ impl str { return s; } + /// Escapes each char in `s` with `char::escape`. + #[unstable(feature = "str_escape", + reason = "return type may change to be an iterator", + issue = "27791")] + pub fn escape(&self) -> String { + self.chars().flat_map(|c| c.escape()).collect() + } + /// Escapes each char in `s` with `char::escape_default`. #[unstable(feature = "str_escape", reason = "return type may change to be an iterator", |
