2
我使用rust-postgres我的結構後提交事務的意圖下面鏽代碼超出範圍不能搬走它定義了`Drop`特質類型[E0509]
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"),
}
}
}
編譯器抱怨以下消息
cannot move out of type `SqlTransaction<'a>`, which defines the `Drop` trait [E0509]at line 12 col 22
發生什麼事,我怎麼能解決這個問題的commit()
線?