Apply suggestions from clippy 1.85

This commit is contained in:
Dirkjan Ochtman 2025-02-21 10:32:15 +01:00
parent 15e287b4fb
commit 11d227a22b
2 changed files with 3 additions and 3 deletions

View File

@ -1142,7 +1142,7 @@ impl NaiveDate {
let mut years = self.year() - base.year();
// Comparing tuples is not (yet) possible in const context. Instead we combine month and
// day into one `u32` for easy comparison.
if (self.month() << 5 | self.day()) < (base.month() << 5 | base.day()) {
if ((self.month() << 5) | self.day()) < ((base.month() << 5) | base.day()) {
years -= 1;
}

View File

@ -181,7 +181,7 @@ fn test_date_from_yo() {
assert_eq!(from_yo(2012, 300), Some(ymd(2012, 10, 26)));
assert_eq!(from_yo(2012, 366), Some(ymd(2012, 12, 31)));
assert_eq!(from_yo(2012, 367), None);
assert_eq!(from_yo(2012, 1 << 28 | 60), None);
assert_eq!(from_yo(2012, (1 << 28) | 60), None);
assert_eq!(from_yo(2014, 0), None);
assert_eq!(from_yo(2014, 1), Some(ymd(2014, 1, 1)));
@ -406,7 +406,7 @@ fn test_date_with_ordinal() {
assert_eq!(d.with_ordinal(61), Some(NaiveDate::from_ymd_opt(2000, 3, 1).unwrap()));
assert_eq!(d.with_ordinal(366), Some(NaiveDate::from_ymd_opt(2000, 12, 31).unwrap()));
assert_eq!(d.with_ordinal(367), None);
assert_eq!(d.with_ordinal(1 << 28 | 60), None);
assert_eq!(d.with_ordinal((1 << 28) | 60), None);
let d = NaiveDate::from_ymd_opt(1999, 5, 5).unwrap();
assert_eq!(d.with_ordinal(366), None);
assert_eq!(d.with_ordinal(u32::MAX), None);