I'm working with ws-rs, and have the below upon open socket:
impl Handler for Client {
fn on_open(&mut self, _: Handshake) -> Result<()> {
println!("sockect: {:#?}", self.out);
Ok(())
}
}
Trying to manipulate self
, as:
pub struct Socket{
socket: Sender,
unique_id: String
}
fn on_open(&mut self, _: Handshake) -> Result<()> {
let socket= Socket{ socket: self.out, unique_id: "".to_string() };
}
But got this error:
error[E0507]: cannot move out of `self.out` which is behind a mutable reference
--> src/socket.rs:35:37
|
35 | let socket= Socket{ socket: self.out, unique_id: "".to_string() };
| ^^^^^^^^ move occurs because `self.out` has type `ws::communication::Sender`, which does not implement the `Copy` trait
It looks I'm not clear about borrowing with &mut