I am new to Rust and I am using the Postgres crate. I am trying to create a wrapper around the PostgreSQL client, and I have defined this Struct:
pub struct PostGresSqlClient {
user_name: String,
host_name: String,
port: String,
client: Client,
}
Later, I am trying to implement the Drop trait on this Struct. Right now, it just tries to close the connection to the Client, but later it may do different things.
impl Drop for PostGresSqlClient {
fn drop(&mut self) {
self.client.close();
}
}
However, I am running into this issue:
error[E0507]: cannot move out of `self.client` which is behind a mutable reference
--> data_lib/src/lib.rs:106:13
|
106 | self.client.close();
| ^^^^^^^^^^^ move occurs because `self.client` has type `Client`, which does not implement the `Copy` trait
I do not know how to resolve this and any help would be appreciated.