Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c60964a

Browse files
Replace Option<&'conn str> with Option<String>
1 parent cf3ead0 commit c60964a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/transaction.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Config {
151151
pub struct Transaction<'conn> {
152152
conn: &'conn Connection,
153153
depth: u32,
154-
savepoint_name: Option<&'conn str>,
154+
savepoint_name: Option<String>,
155155
commit: Cell<bool>,
156156
finished: bool,
157157
}
@@ -198,11 +198,11 @@ impl<'conn> Transaction<'conn> {
198198
let mut conn = self.conn.conn.borrow_mut();
199199
debug_assert!(self.depth == conn.trans_depth);
200200
conn.trans_depth -= 1;
201-
match (self.commit.get(), self.savepoint_name) {
202-
(false, Some(savepoint_name)) => conn.quick_query(&format!("ROLLBACK TO {}", savepoint_name)),
203-
(false, None) => conn.quick_query("ROLLBACK"),
204-
(true, Some(savepoint_name)) => conn.quick_query(&format!("RELEASE {}", savepoint_name)),
205-
(true, None) => conn.quick_query("COMMIT"),
201+
match (self.commit.get(), &self.savepoint_name) {
202+
(false, &Some(ref savepoint_name)) => conn.quick_query(&format!("ROLLBACK TO {}", savepoint_name)),
203+
(false, &None) => conn.quick_query("ROLLBACK"),
204+
(true, &Some(ref savepoint_name)) => conn.quick_query(&format!("RELEASE {}", savepoint_name)),
205+
(true, &None) => conn.quick_query("COMMIT"),
206206
}.map(|_| ())
207207
}
208208

@@ -249,7 +249,7 @@ impl<'conn> Transaction<'conn> {
249249
/// # Panics
250250
///
251251
/// Panics if there is an active nested transaction.
252-
pub fn savepoint<'a>(&'a self, name: &'a str) -> Result<Transaction<'a>> {
252+
pub fn savepoint<'a>(&'a self, name: &str) -> Result<Transaction<'a>> {
253253
let mut conn = self.conn.conn.borrow_mut();
254254
check_desync!(conn);
255255
assert!(conn.trans_depth == self.depth,
@@ -259,7 +259,7 @@ impl<'conn> Transaction<'conn> {
259259
Ok(Transaction {
260260
conn: self.conn,
261261
depth: self.depth + 1,
262-
savepoint_name: Some(name),
262+
savepoint_name: Some(name.to_owned()),
263263
commit: Cell::new(false),
264264
finished: false,
265265
})

0 commit comments

Comments
 (0)