diff options
| author | kennytm <kennytm@gmail.com> | 2018-03-06 16:25:41 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-03-06 20:52:32 +0800 |
| commit | b691c521bb079dda26b9d37d00662fafeb87f783 (patch) | |
| tree | 5c297b7f1da341d4169d92835b6c548a7c304083 /src/libstd | |
| parent | 7dc3f17ef999940a4337a5ea5823acb5c3da65e4 (diff) | |
| parent | 2e7e68b76223b9f14b54852584a5334f33a8798d (diff) | |
| download | rust-b691c521bb079dda26b9d37d00662fafeb87f783.tar.gz rust-b691c521bb079dda26b9d37d00662fafeb87f783.zip | |
Rollup merge of #48754 - leodasvacas:while-let-all-the-things, r=rkruppe
while let all the things
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys_common/wtf8.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 46d554d6411..9fff8b91f96 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -428,20 +428,15 @@ impl fmt::Debug for Wtf8 { formatter.write_str("\"")?; let mut pos = 0; - loop { - match self.next_surrogate(pos) { - None => break, - Some((surrogate_pos, surrogate)) => { - write_str_escaped( - formatter, - unsafe { str::from_utf8_unchecked( - &self.bytes[pos .. surrogate_pos] - )}, - )?; - write!(formatter, "\\u{{{:x}}}", surrogate)?; - pos = surrogate_pos + 3; - } - } + while let Some((surrogate_pos, surrogate)) = self.next_surrogate(pos) { + write_str_escaped( + formatter, + unsafe { str::from_utf8_unchecked( + &self.bytes[pos .. surrogate_pos] + )}, + )?; + write!(formatter, "\\u{{{:x}}}", surrogate)?; + pos = surrogate_pos + 3; } write_str_escaped( formatter, |
