Skip to content

Commit

Permalink
Derive Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Dec 4, 2023
1 parent c9c71b6 commit 82106b0
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions yamux/src/connection/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,12 @@ impl quickcheck::Arbitrary for Rtt {
}

#[derive(Debug)]
#[cfg_attr(test, derive(Clone))]
struct RttInner {
state: RttState,
rtt: Option<Duration>,
}

#[cfg(test)]
impl Clone for RttInner {
fn clone(&self) -> Self {
Self {
state: self.state.clone(),
rtt: self.rtt.clone(),
}
}
}

#[cfg(test)]
impl quickcheck::Arbitrary for RttInner {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
Expand All @@ -131,26 +122,13 @@ impl quickcheck::Arbitrary for RttInner {
}

#[derive(Debug)]
#[cfg_attr(test, derive(Clone))]
enum RttState {
Initial,
AwaitingPong { sent_at: Instant, nonce: u32 },
Waiting { next: Instant },
}

#[cfg(test)]
impl Clone for RttState {
fn clone(&self) -> Self {
match self {
Self::Initial => Self::Initial,
Self::AwaitingPong { sent_at, nonce } => Self::AwaitingPong {
sent_at: sent_at.clone(),
nonce: nonce.clone(),
},
Self::Waiting { next } => Self::Waiting { next: next.clone() },
}
}
}

#[cfg(test)]
impl quickcheck::Arbitrary for RttState {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
Expand Down

0 comments on commit 82106b0

Please sign in to comment.