Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate derives on ArchivedT types (for rkyv feature) #1271

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
/// This also allows for the negative duration; see individual methods for details.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))

Check warning on line 57 in src/duration.rs

View check run for this annotation

Codecov / codecov/patch

src/duration.rs#L57

Added line #L57 was not covered by tests
)]
pub struct Duration {
secs: i64,
nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC
Expand Down
4 changes: 4 additions & 0 deletions src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))

Check warning on line 36 in src/month.rs

View check run for this annotation

Codecov / codecov/patch

src/month.rs#L36

Added line #L36 was not covered by tests
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum Month {
/// January
Expand Down
4 changes: 4 additions & 0 deletions src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
/// [proleptic Gregorian date]: crate::NaiveDate#calendar-date
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))

Check warning on line 197 in src/naive/date.rs

View check run for this annotation

Codecov / codecov/patch

src/naive/date.rs#L197

Added line #L197 was not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deriving those traits for the archived type pretty much makes us promise that NaiveDate will not be modified in a way that makes comparing the type any different from a plain integer. But I think that is a useful property anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If DateImpl changes you'll have to implement Eq/Ord in a way consistent with the current implementation, in which case it should be possible to implement rkyv traits and Eq/Ord on the Archived type in the same way. What I mean is, unless I'm misunderstanding, deriving traits for the Archived type doesn't make you promise anything you don't promise already.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. But that is not all that easy, and would amount to deserializing the Archived type. That seems to defeat the purpose.

Anyway I think we are good.

)]
pub struct NaiveDate {
ymdf: DateImpl, // (year << 13) | of
}
Expand Down
4 changes: 4 additions & 0 deletions src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
/// ```
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))

Check warning on line 79 in src/naive/datetime/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/naive/datetime/mod.rs#L79

Added line #L79 was not covered by tests
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct NaiveDateTime {
date: NaiveDate,
Expand Down
4 changes: 4 additions & 0 deletions src/naive/isoweek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
/// via the [`Datelike::iso_week`](../trait.Datelike.html#tymethod.iso_week) method.
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))

Check warning on line 23 in src/naive/isoweek.rs

View check run for this annotation

Codecov / codecov/patch

src/naive/isoweek.rs#L23

Added line #L23 was not covered by tests
)]
pub struct IsoWeek {
// note that this allows for larger year range than `NaiveDate`.
// this is crucial because we have an edge case for the first and last week supported,
Expand Down
4 changes: 4 additions & 0 deletions src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ mod tests;
/// **there is absolutely no guarantee that the leap second read has actually happened**.
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Copy, Clone)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(
feature = "rkyv",
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
)]
pub struct NaiveTime {
secs: u32,
frac: u32,
Expand Down
1 change: 1 addition & 0 deletions src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/// [`west_opt`](#method.west_opt) methods for examples.
#[derive(PartialEq, Eq, Hash, Copy, Clone)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "rkyv", archive_attr(derive(Clone, Copy, PartialEq, Eq, Hash, Debug)))]

Check warning on line 27 in src/offset/fixed.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/fixed.rs#L27

Added line #L27 was not covered by tests
pub struct FixedOffset {
local_minus_utc: i32,
}
Expand Down
1 change: 1 addition & 0 deletions src/offset/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
/// ```
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "rkyv", archive_attr(derive(Clone, Copy, Debug)))]

Check warning on line 108 in src/offset/local/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/local/mod.rs#L108

Added line #L108 was not covered by tests
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Local;

Expand Down
1 change: 1 addition & 0 deletions src/offset/utc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
/// ```
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "rkyv", archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash)))]

Check warning on line 45 in src/offset/utc.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/utc.rs#L45

Added line #L45 was not covered by tests
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Utc;

Expand Down
1 change: 1 addition & 0 deletions src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
#[cfg_attr(feature = "rustc-serialize", derive(RustcEncodable, RustcDecodable))]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "rkyv", archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash)))]

Check warning on line 35 in src/weekday.rs

View check run for this annotation

Codecov / codecov/patch

src/weekday.rs#L35

Added line #L35 was not covered by tests
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum Weekday {
/// Monday.
Expand Down
Loading