From 4a70e160fbfde500baeea1dd7cccf6d80ca0d828 Mon Sep 17 00:00:00 2001 From: Brandon W Maister Date: Fri, 23 Jun 2017 15:02:58 -0500 Subject: [PATCH] Fix Clippy lints: or_fun_call --- src/format/scan.rs | 6 ++++-- src/format/strftime.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/format/scan.rs b/src/format/scan.rs index 345b842..a492202 100644 --- a/src/format/scan.rs +++ b/src/format/scan.rs @@ -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(s: &str, colon: F) -> ParseResult<(&str, i32)> pub fn timezone_offset_2822(s: &str) -> ParseResult<(&str, Option)> { // 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..]; diff --git a/src/format/strftime.rs b/src/format/strftime.rs index da85579..fdf490c 100644 --- a/src/format/strftime.rs +++ b/src/format/strftime.rs @@ -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..];