-
Notifications
You must be signed in to change notification settings - Fork 222
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
Conversation
@@ -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)] |
There was a problem hiding this comment.
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(),
}
}
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Problem
the crate
derivative
seems to be unmaintained: mcarton/rust-derivative#117Summary of Changes
Alternatives considered:
https://crates.io/crates/derive_more(EDIT: turned out not to be usable)fyi, after this pr, the
derivative
is still used by other transitive deps (i.e. included inCargo.lock
.). Also,educe
andderive_more
are also used by yet other transtive deps.