Skip to content

Refactored libfmt_macros following clippy suggestions #28163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
}
Expand Down