Skip to content

Commit

Permalink
Implement Clone manually
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Jun 1, 2024
1 parent 18eca5b commit 864eb64
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lighthouse-client/src/lighthouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use tracing::{warn, error, debug, info};
use crate::{Check, Error, Result, Spawner};

/// A connection to the lighthouse server for sending requests and receiving events.
#[derive(Clone)]
pub struct Lighthouse<S> {
/// The sink-part of the WebSocket connection.
ws_sink: Arc<Mutex<SplitSink<S, Message>>>,
Expand Down Expand Up @@ -296,3 +295,18 @@ impl<S> Lighthouse<S>
&self.authentication
}
}

// For some reason `#[derive(Clone)]` adds the trait bound `S: Clone`, despite
// not actually being needed since the WebSocket sink is already wrapped in an
// `Arc`, therefore we implement `Clone` manually.

impl<S> Clone for Lighthouse<S> {
fn clone(&self) -> Self {
Self {
ws_sink: self.ws_sink.clone(),
slots: self.slots.clone(),
authentication: self.authentication.clone(),
request_id: self.request_id.clone(),
}
}
}

0 comments on commit 864eb64

Please sign in to comment.