|
77 | 77 | //! - [`NaiveTime`](https://docs.rs/chrono/0.4.38/chrono/naive/struct.NaiveTime.html) |
78 | 78 | //! - `chrono-clock` for: |
79 | 79 | //! - [`Local`](https://docs.rs/chrono/0.4.38/chrono/struct.Local.html) |
| 80 | +//! - `jiff` for: |
| 81 | +//! - [`Zoned`](https://docs.rs/jiff/0.1.1/jiff/struct.Zoned.html) |
| 82 | +//! - [`Timestamp`](https://docs.rs/jiff/0.1.1/jiff/struct.Timestamp.html) |
| 83 | +//! - [`DateTime`](https://docs.rs/jiff/0.1.1/jiff/civil/struct.DateTime.html) |
| 84 | +//! - [`Date`](https://docs.rs/jiff/0.1.1/jiff/civil/struct.Date.html) |
| 85 | +//! - [`Time`](https://docs.rs/jiff/0.1.1/jiff/civil/struct.Time.html) |
80 | 86 | //! |
81 | 87 | //! # Examples |
82 | 88 | //! |
@@ -1021,6 +1027,38 @@ make_copy_impl!(chrono::naive::NaiveTime); |
1021 | 1027 | make_copy_impl!(chrono::Local); |
1022 | 1028 | // No implementation for chrono::NaiveWeek as it's not Copy nor Clone. |
1023 | 1029 |
|
| 1030 | +#[cfg(feature = "jiff")] |
| 1031 | +/// [`ToBoundedStatic`] impl for `jiff::Zoned`. |
| 1032 | +impl ToBoundedStatic for jiff::Zoned { |
| 1033 | + type Static = Self; |
| 1034 | + |
| 1035 | + fn to_static(&self) -> Self::Static { |
| 1036 | + self.clone() |
| 1037 | + } |
| 1038 | +} |
| 1039 | + |
| 1040 | +#[cfg(feature = "jiff")] |
| 1041 | +/// No-op [`IntoBoundedStatic`] impl for `jiff::Zoned`. |
| 1042 | +impl IntoBoundedStatic for jiff::Zoned { |
| 1043 | + type Static = Self; |
| 1044 | + |
| 1045 | + fn into_static(self) -> Self::Static { |
| 1046 | + self |
| 1047 | + } |
| 1048 | +} |
| 1049 | + |
| 1050 | +#[cfg(feature = "jiff")] |
| 1051 | +make_copy_impl!(jiff::Timestamp); |
| 1052 | + |
| 1053 | +#[cfg(feature = "jiff")] |
| 1054 | +make_copy_impl!(jiff::civil::DateTime); |
| 1055 | + |
| 1056 | +#[cfg(feature = "jiff")] |
| 1057 | +make_copy_impl!(jiff::civil::Date); |
| 1058 | + |
| 1059 | +#[cfg(feature = "jiff")] |
| 1060 | +make_copy_impl!(jiff::civil::Time); |
| 1061 | + |
1024 | 1062 | #[cfg(test)] |
1025 | 1063 | mod core_tests { |
1026 | 1064 | use super::*; |
@@ -1931,3 +1969,53 @@ mod chrono_clock_tests { |
1931 | 1969 | ensure_static(to_static); |
1932 | 1970 | } |
1933 | 1971 | } |
| 1972 | + |
| 1973 | +#[cfg(feature = "jiff")] |
| 1974 | +#[cfg(test)] |
| 1975 | +mod jiff_tests { |
| 1976 | + use super::*; |
| 1977 | + |
| 1978 | + fn ensure_static<T: 'static>(t: T) { |
| 1979 | + drop(t); |
| 1980 | + } |
| 1981 | + |
| 1982 | + #[cfg(feature = "std")] |
| 1983 | + #[test] |
| 1984 | + fn test_jiff_zoned() { |
| 1985 | + let value = jiff::Zoned::now(); |
| 1986 | + let to_static = value.to_static(); |
| 1987 | + ensure_static(to_static); |
| 1988 | + } |
| 1989 | + |
| 1990 | + #[cfg(feature = "std")] |
| 1991 | + #[test] |
| 1992 | + fn test_jiff_timestamp() { |
| 1993 | + let value = jiff::Timestamp::now(); |
| 1994 | + let to_static = value.to_static(); |
| 1995 | + ensure_static(to_static); |
| 1996 | + } |
| 1997 | + |
| 1998 | + #[cfg(feature = "std")] |
| 1999 | + #[test] |
| 2000 | + fn test_jiff_civil_datetime() { |
| 2001 | + let value = jiff::civil::DateTime::default(); |
| 2002 | + let to_static = value.to_static(); |
| 2003 | + ensure_static(to_static); |
| 2004 | + } |
| 2005 | + |
| 2006 | + #[cfg(feature = "std")] |
| 2007 | + #[test] |
| 2008 | + fn test_jiff_civil_date() { |
| 2009 | + let value = jiff::civil::Date::default(); |
| 2010 | + let to_static = value.to_static(); |
| 2011 | + ensure_static(to_static); |
| 2012 | + } |
| 2013 | + |
| 2014 | + #[cfg(feature = "std")] |
| 2015 | + #[test] |
| 2016 | + fn test_jiff_civil_time() { |
| 2017 | + let value = jiff::civil::Time::default(); |
| 2018 | + let to_static = value.to_static(); |
| 2019 | + ensure_static(to_static); |
| 2020 | + } |
| 2021 | +} |
0 commit comments