I have the following Rust code using rust-postgres with the intention of committing a transaction after my struct goes out of scope
struct SqlTransaction<'a> {
connection: &'a Connection,
transaction: Transaction<'a>,
}
impl<'a> Drop for SqlTransaction<'a> {
fn drop(&mut self) {
let result = self.transaction.commit();
match result {
Ok(_) => print!("herp"),
Error => print!("lol"),
}
}
}
The compiler complains about the commit()
line with the following message
cannot move out of type `SqlTransaction<'a>`, which defines the `Drop` trait [E0509]at line 12 col 22
What is happening and how can I fix that?