Skip to content

Commit ca5e1e1

Browse files
committed
Remove workaround for Rust < 1.61
1 parent baa55d0 commit ca5e1e1

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/datetime/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ impl<Tz: TimeZone> DateTime<Tz> {
9393
/// ```
9494
#[inline]
9595
#[must_use]
96-
pub fn from_naive_utc_and_offset(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime<Tz> {
96+
pub const fn from_naive_utc_and_offset(
97+
datetime: NaiveDateTime,
98+
offset: Tz::Offset,
99+
) -> DateTime<Tz> {
97100
DateTime { datetime, offset }
98101
}
99102

@@ -655,14 +658,6 @@ impl DateTime<Utc> {
655658
NaiveDateTime::from_timestamp_millis(millis).as_ref().map(NaiveDateTime::and_utc)
656659
}
657660

658-
// FIXME: remove when our MSRV is 1.61+
659-
// This method is used by `NaiveDateTime::and_utc` because `DateTime::from_naive_utc_and_offset`
660-
// can't be made const yet.
661-
// Trait bounds in const function / implementation blocks were not supported until 1.61.
662-
pub(crate) const fn from_naive_utc(datetime: NaiveDateTime) -> Self {
663-
DateTime { datetime, offset: Utc }
664-
}
665-
666661
/// The Unix Epoch, 1970-01-01 00:00:00 UTC.
667662
pub const UNIX_EPOCH: Self = Self { datetime: NaiveDateTime::UNIX_EPOCH, offset: Utc };
668663
}

src/naive/datetime/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,7 @@ impl NaiveDateTime {
10661066
/// ```
10671067
#[must_use]
10681068
pub const fn and_utc(&self) -> DateTime<Utc> {
1069-
// FIXME: use `DateTime::from_naive_utc_and_offset` when our MSRV is 1.61+.
1070-
DateTime::from_naive_utc(*self)
1069+
DateTime::from_naive_utc_and_offset(*self, Utc)
10711070
}
10721071

10731072
/// The minimum possible `NaiveDateTime`.

0 commit comments

Comments
 (0)