Skip to content

Commit 31a615d

Browse files
committed
Implement Clone manually
1 parent 49e616c commit 31a615d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lighthouse-client/src/lighthouse.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use tracing::{warn, error, debug, info};
99
use crate::{Check, Error, Result, Spawner};
1010

1111
/// A connection to the lighthouse server for sending requests and receiving events.
12-
#[derive(Clone)]
1312
pub struct Lighthouse<S> {
1413
/// The sink-part of the WebSocket connection.
1514
ws_sink: Arc<Mutex<SplitSink<S, Message>>>,
@@ -307,3 +306,18 @@ impl<S> Lighthouse<S>
307306
Ok(self.ws_sink.lock().await.close().await?)
308307
}
309308
}
309+
310+
// For some reason `#[derive(Clone)]` adds the trait bound `S: Clone`, despite
311+
// not actually being needed since the WebSocket sink is already wrapped in an
312+
// `Arc`, therefore we implement `Clone` manually.
313+
314+
impl<S> Clone for Lighthouse<S> {
315+
fn clone(&self) -> Self {
316+
Self {
317+
ws_sink: self.ws_sink.clone(),
318+
slots: self.slots.clone(),
319+
authentication: self.authentication.clone(),
320+
request_id: self.request_id.clone(),
321+
}
322+
}
323+
}

0 commit comments

Comments
 (0)