diff --git a/src/format/parsed.rs b/src/format/parsed.rs index 6fcdd60e82..32c6c7afbf 100644 --- a/src/format/parsed.rs +++ b/src/format/parsed.rs @@ -22,7 +22,7 @@ use crate::{Datelike, Timelike}; /// /// - `to_*` methods try to make a concrete date and time value out of set fields. /// It fully checks any remaining out-of-range conditions and inconsistent/impossible fields. -#[derive(Clone, PartialEq, Debug, Default)] +#[derive(Clone, PartialEq, Eq, Debug, Default)] pub struct Parsed { /// Year. /// diff --git a/src/month.rs b/src/month.rs index 6490abfd8b..e8a54bf879 100644 --- a/src/month.rs +++ b/src/month.rs @@ -201,7 +201,7 @@ impl Months { } /// An error resulting from reading `` value with `FromStr`. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Eq)] pub struct ParseMonthError { pub(crate) _dummy: (), } diff --git a/src/naive/date.rs b/src/naive/date.rs index dfe3598319..0c17a79b4e 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -207,7 +207,7 @@ fn test_date_bounds() { impl NaiveDate { /// Makes a new `NaiveDate` from year and packed ordinal-flags, with a verification. fn from_of(year: i32, of: Of) -> Option { - if year >= MIN_YEAR && year <= MAX_YEAR && of.valid() { + if (MIN_YEAR..=MAX_YEAR).contains(&year) && of.valid() { let Of(of) = of; Some(NaiveDate { ymdf: (year << 13) | (of as DateImpl) }) } else { diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index a810c727b8..f882ccd454 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -536,7 +536,6 @@ impl NaiveTime { /// assert_eq!(from_hms(3, 4, 5).overflowing_add_signed(Duration::hours(-7)), /// (from_hms(20, 4, 5), -86_400)); /// ``` - #[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] pub fn overflowing_add_signed(&self, mut rhs: OldDuration) -> (NaiveTime, i64) { let mut secs = self.secs; let mut frac = self.frac; @@ -585,7 +584,7 @@ impl NaiveTime { frac -= 1_000_000_000; secs += 1; } - debug_assert!(-86_400 <= secs && secs < 2 * 86_400); + debug_assert!((-86_400..2 * 86_400).contains(&secs)); debug_assert!((0..1_000_000_000).contains(&frac)); if secs < 0 { diff --git a/src/offset/local/tz_info/parser.rs b/src/offset/local/tz_info/parser.rs index dfbcf7c2df..77f8e481b5 100644 --- a/src/offset/local/tz_info/parser.rs +++ b/src/offset/local/tz_info/parser.rs @@ -229,7 +229,7 @@ impl<'a> Cursor<'a> { } pub(crate) fn peek(&self) -> Option<&u8> { - self.remaining().get(0) + self.remaining().first() } /// Returns remaining data diff --git a/src/offset/local/tz_info/rule.rs b/src/offset/local/tz_info/rule.rs index 69f6264e7a..7befddb5cf 100644 --- a/src/offset/local/tz_info/rule.rs +++ b/src/offset/local/tz_info/rule.rs @@ -399,7 +399,7 @@ fn parse_rule_time(cursor: &mut Cursor) -> Result { fn parse_rule_time_extended(cursor: &mut Cursor) -> Result { let (sign, hour, minute, second) = parse_signed_hhmmss(cursor)?; - if hour < -167 || hour > 167 { + if !(-167..=167).contains(&hour) { return Err(Error::InvalidTzString("invalid day time hour")); } if !(0..=59).contains(&minute) { diff --git a/src/weekday.rs b/src/weekday.rs index 03e06570ab..6d2603f5d1 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -186,7 +186,7 @@ impl num_traits::FromPrimitive for Weekday { } /// An error resulting from reading `Weekday` value with `FromStr`. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Eq)] pub struct ParseWeekdayError { pub(crate) _dummy: (), }