From 440421e81a93ee88aa71743536e4e07434264d1e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 29 Aug 2013 01:44:34 -0400 Subject: [PATCH] Minor cleanup --- src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a75a4245..01e2de18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -285,8 +285,7 @@ impl PostgresConnection { }) } - pub fn in_transaction(&self, blk: &fn(&PostgresTransaction) -> T) - -> T { + pub fn in_transaction(&self, blk: &fn(&PostgresTransaction) -> T) -> T { self.quick_query("BEGIN"); let trans = PostgresTransaction { @@ -431,19 +430,22 @@ impl<'self> PostgresStatement<'self> { None => () } - let mut num = 0; + let num; loop { match_read_message!(self.conn, { CommandComplete { tag } => { let s = tag.split_iter(' ').last().unwrap(); - match FromStr::from_str(s) { - None => (), - Some(n) => num = n - } + num = match FromStr::from_str(s) { + None => 0, + Some(n) => n + }; break; }, DataRow {_} => (), - EmptyQueryResponse => break, + EmptyQueryResponse => { + num = 0; + break; + }, NoticeResponse {_} => (), ErrorResponse { fields } => { self.conn.wait_for_ready();