@@ -145,7 +145,7 @@ impl Rtcc for Rtc {
145
145
}
146
146
147
147
fn set_weekday ( & mut self , weekday : u8 ) -> Result < ( ) , Self :: Error > {
148
- if ( weekday < 1 ) || ( weekday > 7 ) {
148
+ if ! ( 1 ..= 7 ) . contains ( & weekday) {
149
149
return Err ( Error :: InvalidInputData ) ;
150
150
}
151
151
self . modify ( |regs| regs. dr . modify ( |_, w| unsafe { w. wdu ( ) . bits ( weekday) } ) ) ;
@@ -154,7 +154,7 @@ impl Rtcc for Rtc {
154
154
}
155
155
156
156
fn set_day ( & mut self , day : u8 ) -> Result < ( ) , Self :: Error > {
157
- if ( day < 1 ) || ( day > 31 ) {
157
+ if ! ( 1 ..= 31 ) . contains ( & day) {
158
158
return Err ( Error :: InvalidInputData ) ;
159
159
}
160
160
let ( dt, du) = bcd2_encode ( day as u32 ) ?;
@@ -164,7 +164,7 @@ impl Rtcc for Rtc {
164
164
}
165
165
166
166
fn set_month ( & mut self , month : u8 ) -> Result < ( ) , Self :: Error > {
167
- if ( month < 1 ) || ( month > 12 ) {
167
+ if ! ( 1 ..= 12 ) . contains ( & month) {
168
168
return Err ( Error :: InvalidInputData ) ;
169
169
}
170
170
let ( mt, mu) = bcd2_encode ( month as u32 ) ?;
@@ -174,7 +174,7 @@ impl Rtcc for Rtc {
174
174
}
175
175
176
176
fn set_year ( & mut self , year : u16 ) -> Result < ( ) , Self :: Error > {
177
- if ( year < 1970 ) || ( year > 2038 ) {
177
+ if ! ( 1970 ..= 2038 ) . contains ( & year) {
178
178
return Err ( Error :: InvalidInputData ) ;
179
179
}
180
180
let ( yt, yu) = bcd2_encode ( year as u32 ) ?;
0 commit comments