Fix Clippy lints: or_fun_call

This commit is contained in:
Brandon W Maister 2017-06-23 15:02:58 -05:00
parent fd6036a8b9
commit 4a70e160fb
2 changed files with 6 additions and 4 deletions

View File

@ -36,7 +36,8 @@ pub fn number(s: &str, min: usize, max: usize) -> ParseResult<(&str, i64)> {
if window.len() > max { window = &window[..max]; }
// scan digits
let upto = window.iter().position(|&c| c < b'0' || b'9' < c).unwrap_or(window.len());
let upto = window.iter().position(|&c| c < b'0' || b'9' < c)
.unwrap_or_else(|| window.len());
if upto < min {
return Err(if window.is_empty() {TOO_SHORT} else {INVALID});
}
@ -224,7 +225,8 @@ pub fn timezone_offset_zulu<F>(s: &str, colon: F) -> ParseResult<(&str, i32)>
pub fn timezone_offset_2822(s: &str) -> ParseResult<(&str, Option<i32>)> {
// tries to parse legacy time zone names
let upto = s.as_bytes().iter().position(|&c| match c { b'a'...b'z' | b'A'...b'Z' => false,
_ => true }).unwrap_or(s.len());
_ => true })
.unwrap_or_else(|| s.len());
if upto > 0 {
let name = &s[..upto];
let s = &s[upto..];

View File

@ -305,7 +305,7 @@ impl<'a> Iterator for StrftimeItems<'a> {
Some(c) if c.is_whitespace() => {
// `%` is not a whitespace, so `c != '%'` is redundant
let nextspec = self.remainder.find(|c: char| !c.is_whitespace())
.unwrap_or(self.remainder.len());
.unwrap_or_else(|| self.remainder.len());
assert!(nextspec > 0);
let item = sp!(&self.remainder[..nextspec]);
self.remainder = &self.remainder[nextspec..];
@ -315,7 +315,7 @@ impl<'a> Iterator for StrftimeItems<'a> {
// the next item is literal
_ => {
let nextspec = self.remainder.find(|c: char| c.is_whitespace() || c == '%')
.unwrap_or(self.remainder.len());
.unwrap_or_else(|| self.remainder.len());
assert!(nextspec > 0);
let item = lit!(&self.remainder[..nextspec]);
self.remainder = &self.remainder[nextspec..];