|
1 | 1 | use super::DateTime;
|
2 | 2 | use crate::naive::{NaiveDate, NaiveTime};
|
3 |
| -use crate::offset::{FixedOffset, TimeZone, Utc}; |
4 | 3 | #[cfg(feature = "clock")]
|
5 |
| -use crate::offset::{Local, Offset}; |
| 4 | +use crate::offset::Local; |
| 5 | +use crate::offset::{FixedOffset, Offset, TimeZone, Utc}; |
6 | 6 | use crate::{Datelike, Days, MappedLocalTime, Months, NaiveDateTime, TimeDelta, Timelike, Weekday};
|
7 | 7 |
|
8 | 8 | #[derive(Clone)]
|
@@ -1318,9 +1318,44 @@ fn test_datetime_format_with_local() {
|
1318 | 1318 |
|
1319 | 1319 | #[test]
|
1320 | 1320 | fn test_datetime_is_send_and_copy() {
|
| 1321 | + #[derive(Clone)] |
| 1322 | + struct Tz { |
| 1323 | + _not_send: *const i32, |
| 1324 | + } |
| 1325 | + impl TimeZone for Tz { |
| 1326 | + type Offset = Off; |
| 1327 | + |
| 1328 | + fn from_offset(_: &Self::Offset) -> Self { |
| 1329 | + unimplemented!() |
| 1330 | + } |
| 1331 | + fn offset_from_local_date(&self, _: &NaiveDate) -> crate::MappedLocalTime<Self::Offset> { |
| 1332 | + unimplemented!() |
| 1333 | + } |
| 1334 | + fn offset_from_local_datetime( |
| 1335 | + &self, |
| 1336 | + _: &NaiveDateTime, |
| 1337 | + ) -> crate::MappedLocalTime<Self::Offset> { |
| 1338 | + unimplemented!() |
| 1339 | + } |
| 1340 | + fn offset_from_utc_date(&self, _: &NaiveDate) -> Self::Offset { |
| 1341 | + unimplemented!() |
| 1342 | + } |
| 1343 | + fn offset_from_utc_datetime(&self, _: &NaiveDateTime) -> Self::Offset { |
| 1344 | + unimplemented!() |
| 1345 | + } |
| 1346 | + } |
| 1347 | + |
| 1348 | + #[derive(Copy, Clone, Debug)] |
| 1349 | + struct Off(()); |
| 1350 | + impl Offset for Off { |
| 1351 | + fn fix(&self) -> FixedOffset { |
| 1352 | + unimplemented!() |
| 1353 | + } |
| 1354 | + } |
| 1355 | + |
1321 | 1356 | fn _assert_send_copy<T: Send + Copy>() {}
|
1322 |
| - // UTC is known to be `Send + Copy`. |
1323 |
| - _assert_send_copy::<DateTime<Utc>>(); |
| 1357 | + // `DateTime` is `Send + Copy` if the offset is. |
| 1358 | + _assert_send_copy::<DateTime<Tz>>(); |
1324 | 1359 | }
|
1325 | 1360 |
|
1326 | 1361 | #[test]
|
|
0 commit comments