Skip to content

Commit

Permalink
Use derivative to avoid manual Clone impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Jan 18, 2024
1 parent f9fbbfb commit 2a046e4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ ctrlc = "3.4.2"
curve25519-dalek = "3.2.1"
dashmap = "5.5.3"
derivation-path = { version = "0.2.0", default-features = false }
derivative = "2.2.0"
dialoguer = "0.10.4"
digest = "0.10.7"
dir-diff = "0.3.3"
Expand Down
1 change: 1 addition & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions unified-scheduler-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ edition = { workspace = true }
[dependencies]
assert_matches = { workspace = true }
crossbeam-channel = { workspace = true }
derivative = { workspace = true }
log = { workspace = true }
solana-ledger = { workspace = true }
solana-program-runtime = { workspace = true }
Expand Down
14 changes: 5 additions & 9 deletions unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use {
assert_matches::assert_matches,
crossbeam_channel::{select, unbounded, Receiver, SendError, Sender},
derivative::Derivative,
log::*,
solana_ledger::blockstore_processor::{
execute_batch, TransactionBatchWithIndexes, TransactionStatusSender,
Expand Down Expand Up @@ -326,20 +327,15 @@ 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"))]
pub(super) struct ChainedChannelReceiver<P, C: Clone> {
receiver: Receiver<ChainedChannel<P, C>>,
context: C,
}

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

impl<P, C: Clone> ChainedChannelReceiver<P, C> {
fn new(receiver: Receiver<ChainedChannel<P, C>>, initial_context: C) -> Self {
Self {
Expand Down

0 comments on commit 2a046e4

Please sign in to comment.