Skip to content

Commit

Permalink
UTC_OFFSET_FORMAT: do not rely on promotion of function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 5, 2024
1 parent f22bced commit 34426ab
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions time/src/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,24 @@ impl<'a> Deserialize<'a> for Time {
// region: UtcOffset
/// The format used when serializing and deserializing a human-readable `UtcOffset`.
#[cfg(feature = "parsing")]
const UTC_OFFSET_HOUR: modifier::OffsetHour = {
let mut m = modifier::OffsetHour::default();
m.sign_is_mandatory = true;
m
};
#[cfg(feature = "parsing")]
const UTC_OFFSET_MINUTE: modifier::OffsetMinute = modifier::OffsetMinute::default();
#[cfg(feature = "parsing")]
const UTC_OFFSET_SECOND: modifier::OffsetSecond = modifier::OffsetSecond::default();
#[cfg(feature = "parsing")]
const UTC_OFFSET_FORMAT: &[BorrowedFormatItem<'_>] = &[
BorrowedFormatItem::Component(Component::OffsetHour({
let mut m = modifier::OffsetHour::default();
m.sign_is_mandatory = true;
m
})),
BorrowedFormatItem::Component(Component::OffsetHour(UTC_OFFSET_HOUR)),
BorrowedFormatItem::Optional(&BorrowedFormatItem::Compound(&[
BorrowedFormatItem::Literal(b":"),
BorrowedFormatItem::Component(Component::OffsetMinute(modifier::OffsetMinute::default())),
BorrowedFormatItem::Component(Component::OffsetMinute(UTC_OFFSET_MINUTE)),
BorrowedFormatItem::Optional(&BorrowedFormatItem::Compound(&[
BorrowedFormatItem::Literal(b":"),
BorrowedFormatItem::Component(Component::OffsetSecond(
modifier::OffsetSecond::default(),
)),
BorrowedFormatItem::Component(Component::OffsetSecond(UTC_OFFSET_SECOND)),
])),
])),
];
Expand Down

0 comments on commit 34426ab

Please sign in to comment.