From 71aa41c27a0f84eb31c7c058ec4008b4cc17d823 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:04:33 -0500 Subject: [PATCH 1/2] rustfmt --- src/lib.rs | 4 +--- src/named_params.rs | 25 ++++++++++++++----------- src/transaction.rs | 9 +++++++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c3b565e..911667f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -965,9 +965,7 @@ pub struct Rows<'stmt> { impl<'stmt> Rows<'stmt> { fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> { - Rows { - stmt: Some(stmt), - } + Rows { stmt: Some(stmt) } } fn get_expected_row<'a>(&'a mut self) -> Result> { diff --git a/src/named_params.rs b/src/named_params.rs index 04ebcbd..d89cc6e 100644 --- a/src/named_params.rs +++ b/src/named_params.rs @@ -279,9 +279,10 @@ mod test { let mut stmt = db.prepare("SELECT id FROM test where name = :name").unwrap(); let mut rows = stmt.query_map_named(&[(":name", &"one")], |row| { - let id: i32 = row.get(0); - 2 * id - }).unwrap(); + let id: i32 = row.get(0); + 2 * id + }) + .unwrap(); let doubled_id: i32 = rows.next().unwrap().unwrap(); assert_eq!(2, doubled_id); @@ -298,15 +299,17 @@ mod test { "#; db.execute_batch(sql).unwrap(); - let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC").unwrap(); + let mut stmt = db.prepare("SELECT id FROM test where name = :name ORDER BY id ASC") + .unwrap(); let mut rows = stmt.query_and_then_named(&[(":name", &"one")], |row| { - let id: i32 = row.get(0); - if id == 1 { - Ok(id) - } else { - Err(Error::SqliteSingleThreadedMode) - } - }).unwrap(); + let id: i32 = row.get(0); + if id == 1 { + Ok(id) + } else { + Err(Error::SqliteSingleThreadedMode) + } + }) + .unwrap(); // first row should be Ok let doubled_id: i32 = rows.next().unwrap().unwrap(); diff --git a/src/transaction.rs b/src/transaction.rs index 3bdae80..e678215 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -209,7 +209,10 @@ impl<'conn> Drop for Transaction<'conn> { } impl<'conn> Savepoint<'conn> { - fn with_depth_and_name>(conn: &Connection, depth: u32, name: T) -> Result { + fn with_depth_and_name>(conn: &Connection, + depth: u32, + name: T) + -> Result { let name = name.into(); conn.execute_batch(&format!("SAVEPOINT {}", name)).map(|_| { Savepoint { @@ -349,7 +352,9 @@ impl Connection { /// # Failure /// /// Will return `Err` if the underlying SQLite call fails. - pub fn transaction_with_behavior(&mut self, behavior: TransactionBehavior) -> Result { + pub fn transaction_with_behavior(&mut self, + behavior: TransactionBehavior) + -> Result { Transaction::new(self, behavior) } From c4417bee0e7694ee4263dccbaca88c73da3dbd94 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Thu, 19 May 2016 20:09:40 -0500 Subject: [PATCH 2/2] Manual fixes for rustfmt overly long lines. --- src/blob.rs | 5 ++++- src/functions.rs | 17 ++++++++++------- src/lib.rs | 9 +++++++-- src/trace.rs | 6 ++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/blob.rs b/src/blob.rs index c24fce9..548e5c9 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -235,7 +235,10 @@ impl<'conn> Drop for Blob<'conn> { } /// BLOB of length N that is filled with zeroes. -/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using incremental BLOB I/O routines. +/// +/// Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using +/// incremental BLOB I/O routines. +/// /// A negative value for the zeroblob results in a zero-length BLOB. #[derive(Copy,Clone)] pub struct ZeroBlob(pub i32); diff --git a/src/functions.rs b/src/functions.rs index 5842880..8c8723e 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -111,7 +111,8 @@ impl<'a> ToResult for &'a str { length as c_int, ffi::SQLITE_TRANSIENT()) } - Err(_) => ffi::sqlite3_result_error_code(ctx, ffi::SQLITE_MISUSE), // TODO sqlite3_result_error + // TODO sqlite3_result_error + Err(_) => ffi::sqlite3_result_error_code(ctx, ffi::SQLITE_MISUSE), } } } @@ -710,9 +711,10 @@ mod test { assert_eq!(true, result.unwrap()); - let result: Result = db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", - &[], - |r| r.get(0)); + let result: Result = + db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", + &[], + |r| r.get(0)); assert_eq!(2, result.unwrap()); } @@ -760,9 +762,10 @@ mod test { assert_eq!(true, result.unwrap()); - let result: Result = db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", - &[], - |r| r.get(0)); + let result: Result = + db.query_row("SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1", + &[], + |r| r.get(0)); assert_eq!(2, result.unwrap()); } diff --git a/src/lib.rs b/src/lib.rs index 911667f..f68da9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -319,7 +319,9 @@ impl Connection { /// ```rust,no_run /// # use rusqlite::{Result,Connection}; /// fn preferred_locale(conn: &Connection) -> Result { - /// conn.query_row_and_then("SELECT value FROM preferences WHERE name='locale'", &[], |row| { + /// conn.query_row_and_then("SELECT value FROM preferences WHERE name='locale'", + /// &[], + /// |row| { /// row.get_checked(0) /// }) /// } @@ -709,9 +711,12 @@ impl<'conn> Statement<'conn> { } /// Returns the column index in the result set for a given column name. - /// If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next. + /// + /// If there is no AS clause then the name of the column is unspecified and may change from one + /// release of SQLite to the next. /// /// # Failure + /// /// Will return an `Error::InvalidColumnName` when there is no column with the specified `name`. pub fn column_index(&self, name: &str) -> Result { let bytes = name.as_bytes(); diff --git a/src/trace.rs b/src/trace.rs index 4cea711..32382a2 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -59,7 +59,8 @@ pub fn log(err_code: c_int, msg: &str) { } impl Connection { - /// Register or clear a callback function that can be used for tracing the execution of SQL statements. + /// Register or clear a callback function that can be used for tracing the execution of SQL + /// statements. /// /// Prepared statement placeholders are replaced/logged with their assigned values. /// There can only be a single tracer defined for each database connection. @@ -83,7 +84,8 @@ impl Connection { } } - /// Register or clear a callback function that can be used for profiling the execution of SQL statements. + /// Register or clear a callback function that can be used for profiling the execution of SQL + /// statements. /// /// There can only be a single profiler defined for each database connection. /// Setting a new profiler clears the old one.