diff options
| author | bors <bors@rust-lang.org> | 2016-05-19 16:22:50 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-19 16:22:50 -0700 |
| commit | 1ec80f65fbc5b16e2b9238ee9888ca242bbb7c5e (patch) | |
| tree | cf3c74593a16043515f6b5524bc16a5aae78d516 /src/libcore/char.rs | |
| parent | 764ef92ae7a26cbb9c2121de3812a0a17739f65f (diff) | |
| parent | 8169fa2fe84b6e3944f7362d3e73ba763a2da1d9 (diff) | |
Auto merge of #33103 - ranma42:escape-unicode-last, r=alexcrichton
Implement `last` for `EscapeUnicode`
The implementation is quite trivial as the last character is always `'{'`.
As a side-effect it also improves the implementation of `last` for `EscapeUnicode`.
Part of #24214, split from #31049.
Maybe this (and the other changes that I will split from #31049) should wait for a test like `ed_iterator_specializations` to be added. Would it be sufficient to do the same for each possible escape length?
Diffstat (limited to 'src/libcore/char.rs')
| -rw-r--r-- | src/libcore/char.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 140403884b9..65b9a27bb68 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -471,6 +471,18 @@ impl Iterator for EscapeUnicode { let n = n + self.hex_digit_idx; (n, Some(n)) } + + fn last(self) -> Option<char> { + match self.state { + EscapeUnicodeState::Done => None, + + EscapeUnicodeState::RightBrace | + EscapeUnicodeState::Value | + EscapeUnicodeState::LeftBrace | + EscapeUnicodeState::Type | + EscapeUnicodeState::Backslash => Some('}'), + } + } } /// An iterator that yields the literal escape code of a `char`. |
