diff options
| author | bors <bors@rust-lang.org> | 2015-09-02 10:20:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-09-02 10:20:41 +0000 |
| commit | 370fe2786109360f7c35b8ba552b83b773dd71d6 (patch) | |
| tree | 1ec4b22d02c127586668a680cf27477346df9e79 | |
| parent | 0dbbab904916236d59446b9f51944a057e7b9966 (diff) | |
| parent | 2a65474221f9b18fdf3b3309024bafc3c38e95fd (diff) | |
| download | rust-370fe2786109360f7c35b8ba552b83b773dd71d6.tar.gz rust-370fe2786109360f7c35b8ba552b83b773dd71d6.zip | |
Auto merge of #28163 - llogiq:master, r=Manishearth
| -rw-r--r-- | src/libfmt_macros/lib.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 69438204730..32a5bd906fc 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -190,7 +190,7 @@ impl<'a> Parser<'a> { /// String, but I think it does when this eventually uses conditions so it /// might as well start using it now. fn err(&mut self, msg: &str) { - self.errors.push(msg.to_string()); + self.errors.push(msg.to_owned()); } /// Optionally consumes the specified character. If the character is not at @@ -353,7 +353,7 @@ impl<'a> Parser<'a> { } else { spec.ty = self.word(); } - return spec; + spec } /// Parses a Count parameter at the current position. This does not check @@ -417,25 +417,19 @@ impl<'a> Parser<'a> { fn integer(&mut self) -> Option<usize> { let mut cur = 0; let mut found = false; - loop { - match self.cur.clone().next() { - Some((_, c)) => { - match c.to_digit(10) { - Some(i) => { - cur = cur * 10 + i as usize; - found = true; - self.cur.next(); - } - None => { break } - } - } - None => { break } + while let Some((_, c)) = self.cur.clone().next() { + if let Some(i) = c.to_digit(10) { + cur = cur * 10 + i as usize; + found = true; + self.cur.next(); + } else { + break } } if found { - return Some(cur); + Some(cur) } else { - return None; + None } } } |
