Skip to content

Commit f45bff5

Browse files
committed
Use const block for readability
1 parent b38c118 commit f45bff5

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

time/src/serde/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -446,27 +446,26 @@ impl<'a> Deserialize<'a> for Time {
446446
}
447447
}
448448

449-
// FIXME: turn these constants into `const { ... }` blocks once we can depend on Rust 1.79.
450-
#[cfg(feature = "parsing")]
451-
const UTC_OFFSET_HOUR: modifier::OffsetHour = {
452-
let mut m = modifier::OffsetHour::default();
453-
m.sign_is_mandatory = true;
454-
m
455-
};
456-
#[cfg(feature = "parsing")]
457-
const UTC_OFFSET_MINUTE: modifier::OffsetMinute = modifier::OffsetMinute::default();
458-
#[cfg(feature = "parsing")]
459-
const UTC_OFFSET_SECOND: modifier::OffsetSecond = modifier::OffsetSecond::default();
460449
/// The format used when serializing and deserializing a human-readable `UtcOffset`.
461450
#[cfg(feature = "parsing")]
462451
const UTC_OFFSET_FORMAT: &[BorrowedFormatItem<'_>] = &[
463-
BorrowedFormatItem::Component(Component::OffsetHour(UTC_OFFSET_HOUR)),
452+
BorrowedFormatItem::Component(Component::OffsetHour(
453+
const {
454+
let mut m = modifier::OffsetHour::default();
455+
m.sign_is_mandatory = true;
456+
m
457+
},
458+
)),
464459
BorrowedFormatItem::Optional(&BorrowedFormatItem::Compound(&[
465460
BorrowedFormatItem::Literal(b":"),
466-
BorrowedFormatItem::Component(Component::OffsetMinute(UTC_OFFSET_MINUTE)),
461+
BorrowedFormatItem::Component(Component::OffsetMinute(
462+
const { modifier::OffsetMinute::default() },
463+
)),
467464
BorrowedFormatItem::Optional(&BorrowedFormatItem::Compound(&[
468465
BorrowedFormatItem::Literal(b":"),
469-
BorrowedFormatItem::Component(Component::OffsetSecond(UTC_OFFSET_SECOND)),
466+
BorrowedFormatItem::Component(Component::OffsetSecond(
467+
const { modifier::OffsetSecond::default() },
468+
)),
470469
])),
471470
])),
472471
];

0 commit comments

Comments
 (0)