@@ -404,22 +404,27 @@ impl<'a> Deserialize<'a> for Time {
404
404
// endregion Time
405
405
406
406
// region: UtcOffset
407
+ // FIXME: turn these constants into `const { ... }` blocks once we can depend on Rust 1.79.
408
+ #[ cfg( feature = "parsing" ) ]
409
+ const UTC_OFFSET_HOUR : modifier:: OffsetHour = {
410
+ let mut m = modifier:: OffsetHour :: default ( ) ;
411
+ m. sign_is_mandatory = true ;
412
+ m
413
+ } ;
414
+ #[ cfg( feature = "parsing" ) ]
415
+ const UTC_OFFSET_MINUTE : modifier:: OffsetMinute = modifier:: OffsetMinute :: default ( ) ;
416
+ #[ cfg( feature = "parsing" ) ]
417
+ const UTC_OFFSET_SECOND : modifier:: OffsetSecond = modifier:: OffsetSecond :: default ( ) ;
407
418
/// The format used when serializing and deserializing a human-readable `UtcOffset`.
408
419
#[ cfg( feature = "parsing" ) ]
409
420
const UTC_OFFSET_FORMAT : & [ BorrowedFormatItem < ' _ > ] = & [
410
- BorrowedFormatItem :: Component ( Component :: OffsetHour ( {
411
- let mut m = modifier:: OffsetHour :: default ( ) ;
412
- m. sign_is_mandatory = true ;
413
- m
414
- } ) ) ,
421
+ BorrowedFormatItem :: Component ( Component :: OffsetHour ( UTC_OFFSET_HOUR ) ) ,
415
422
BorrowedFormatItem :: Optional ( & BorrowedFormatItem :: Compound ( & [
416
423
BorrowedFormatItem :: Literal ( b":" ) ,
417
- BorrowedFormatItem :: Component ( Component :: OffsetMinute ( modifier :: OffsetMinute :: default ( ) ) ) ,
424
+ BorrowedFormatItem :: Component ( Component :: OffsetMinute ( UTC_OFFSET_MINUTE ) ) ,
418
425
BorrowedFormatItem :: Optional ( & BorrowedFormatItem :: Compound ( & [
419
426
BorrowedFormatItem :: Literal ( b":" ) ,
420
- BorrowedFormatItem :: Component ( Component :: OffsetSecond (
421
- modifier:: OffsetSecond :: default ( ) ,
422
- ) ) ,
427
+ BorrowedFormatItem :: Component ( Component :: OffsetSecond ( UTC_OFFSET_SECOND ) ) ,
423
428
] ) ) ,
424
429
] ) ) ,
425
430
] ;
0 commit comments