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

Replace unmaintained derivative with derive-where #3402

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Oct 31, 2024

Problem

the crate derivative seems to be unmaintained: mcarton/rust-derivative#117

Summary of Changes

Alternatives considered:

fyi, after this pr, the derivative is still used by other transitive deps (i.e. included in Cargo.lock.). Also, educe and derive_more are also used by yet other transtive deps.

@ryoqun ryoqun changed the title Use derive-where instead of unmaintained derivative Replace unmaintained derivative with derive-where Oct 31, 2024
@ryoqun ryoqun marked this pull request as ready for review October 31, 2024 05:13
@ryoqun ryoqun requested a review from apfitzge October 31, 2024 05:14
@@ -569,8 +569,7 @@ mod chained_channel {

// P doesn't need to be `: Clone`, yet rustc derive can't handle it.
// see https://github.com/rust-lang/rust/issues/26925
#[derive(Derivative)]
#[derivative(Clone(bound = "C: Clone"))]
#[derive_where(Clone)]

Choose a reason for hiding this comment

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

thoughts on just implementing Clone here instead of adding another dependency that may become stale in the future. It seems really straight-forward:

impl<P, C: Clone> Clone for ChainedChannelReceiver<P, C> {
    fn clone(&self) -> Self {
        Self {
            reciever: self.receiver.clone(),
            aux_receiver: self.aux_receiver.clone(),
            context: self.context.clone(),
        }
    }
} 

Copy link
Member Author

@ryoqun ryoqun Nov 5, 2024

Choose a reason for hiding this comment

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

@apfitzge sorry for the delay. took some time to consolidate my thoughts with some research.

in short, I'd like to avoid manual impl and use this new crate (the one called derive-where, among others with omitted reasons after long evaluation.) for following personal preferences:

  • i'm generally inclined to using crates as much as possible because I'm open-source maxi and upstreaming-pr happy guy :)
  • i'm moderately against boilerplate code, which is error-prone, imo. yes, to recite, I'm saying this, even if we're talking about straight-forward manual impl of just 9 LoC. (less code == less maintenance; in fact, upcoming pr would have to tweak the manual impl.)
  • oftentimes, crate shopping (shh, my hobby) could refresh one's rust knowledge. so, i hope this habit could be rewarded in some way. for example, i noticed ImmutableDeserializedPacket can be simplified.
  • in this particular case, switching cost is very small, should the new one could be stale (unlike say, bincode, which would break our wire-format should we switch).
  • i think (slightly) longer build time by adding another dep can generally be offset by increased productivity or concise code base in this case.
  • thanks to rust opt, all tested clone impls (std, manual, those crates mentioned on this pr) generates the same machine code.

Copy link

Choose a reason for hiding this comment

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

😄 ImmutableDeserializedPacket is awful and is going to go away entirely, which is the simplest it can become.

@ryoqun ryoqun requested a review from apfitzge November 5, 2024 14:13
@ryoqun ryoqun merged commit a3f6c7d into anza-xyz:master Nov 6, 2024
51 checks passed
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.

2 participants