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

manually implement Copy on DateTime<Tz> #1572

Closed
wants to merge 1 commit into from

Conversation

little-dude
Copy link

derive generates the following impls:

impl<Tz: ::core::marker::Copy + TimeZone> ::core::marker::Copy for DateTime<Tz>
where
    Tz::Offset: ::core::marker::Copy,
{}

impl<Tz: ::core::clone::Clone + TimeZone> ::core::clone::Clone for DateTime<Tz>
where
    Tz::Offset: ::core::clone::Clone,
{
    #[inline]
    fn clone(&self) -> DateTime<Tz> {
        DateTime {
            datetime: ::core::clone::Clone::clone(&self.datetime),
            offset: ::core::clone::Clone::clone(&self.offset),
        }
    }
}

In the Copy impl, the Tz: Copy bound is un-necessary. Note that in the Clone impl, he Tz: Clone is also un-necessary, but it's implied by the TimeZone bound anyway, so there's not point having a manual implementation of Clone.

Fixes #1571

`derive` generates the following impls:

```rust
impl<Tz: ::core::marker::Copy + TimeZone> ::core::marker::Copy for DateTime<Tz>
where
    Tz::Offset: ::core::marker::Copy,
{}

impl<Tz: ::core::clone::Clone + TimeZone> ::core::clone::Clone for DateTime<Tz>
where
    Tz::Offset: ::core::clone::Clone,
{
    #[inline]
    fn clone(&self) -> DateTime<Tz> {
        DateTime {
            datetime: ::core::clone::Clone::clone(&self.datetime),
            offset: ::core::clone::Clone::clone(&self.offset),
        }
    }
}
```

In the `Copy` impl, the `Tz: Copy` bound is un-necessary. Note that in
the `Clone` impl, he `Tz: Clone` is also un-necessary, but it's
implied by the `TimeZone` bound anyway, so there's not point having a
manual implementation of `Clone`.

Fixes chronotope#1571
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.82%. Comparing base (760eb66) to head (359d1e2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1572   +/-   ##
=======================================
  Coverage   91.82%   91.82%           
=======================================
  Files          37       37           
  Lines       18173    18173           
=======================================
  Hits        16687    16687           
  Misses       1486     1486           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@little-dude
Copy link
Author

Closing in favor of #1573

@pitdicker
Copy link
Collaborator

We were pretty much at the same time, thank you for working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.4.37 semver-incompatibly removes trait bounds on DateTime
2 participants