From e0793a38a6bb06cbc99131c84d80dbdd9d2f3ced Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sat, 26 Aug 2017 07:52:28 +0200 Subject: [PATCH] Run rustfmt (nightly) --- benches/lib.rs | 31 ++++++++++--------------------- src/lib.rs | 2 +- tests/lib.rs | 17 +++++------------ 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/benches/lib.rs b/benches/lib.rs index 911afe5..dd8d3c3 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -13,9 +13,7 @@ macro_rules! ok(($result:expr) => ($result.unwrap())); fn read_cursor(bencher: &mut Bencher) { let connection = create(); populate(&connection, 100); - let mut cursor = ok!(connection.prepare( - "SELECT * FROM data WHERE a > ? AND b > ?", - )).cursor(); + let mut cursor = ok!(connection.prepare("SELECT * FROM data WHERE a > ? AND b > ?")).cursor(); bencher.iter(|| { ok!(cursor.bind(&[Integer(42), Float(42.0)])); @@ -30,9 +28,7 @@ fn read_cursor(bencher: &mut Bencher) { fn read_statement(bencher: &mut Bencher) { let connection = create(); populate(&connection, 100); - let mut statement = ok!(connection.prepare( - "SELECT * FROM data WHERE a > ? AND b > ?", - )); + let mut statement = ok!(connection.prepare("SELECT * FROM data WHERE a > ? AND b > ?")); bencher.iter(|| { ok!(statement.reset()); @@ -48,14 +44,11 @@ fn read_statement(bencher: &mut Bencher) { #[bench] fn write_cursor(bencher: &mut Bencher) { let connection = create(); - let mut cursor = ok!(connection.prepare( - "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", - )).cursor(); + let mut cursor = + ok!(connection.prepare("INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)")).cursor(); bencher.iter(|| { - ok!(cursor.bind( - &[Integer(42), Float(42.0), Float(42.0), Float(42.0)], - )); + ok!(cursor.bind(&[Integer(42), Float(42.0), Float(42.0), Float(42.0)])); ok!(cursor.next()); }) } @@ -63,9 +56,8 @@ fn write_cursor(bencher: &mut Bencher) { #[bench] fn write_statement(bencher: &mut Bencher) { let connection = create(); - let mut statement = ok!(connection.prepare( - "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", - )); + let mut statement = + ok!(connection.prepare("INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)")); bencher.iter(|| { ok!(statement.reset()); @@ -79,16 +71,13 @@ fn write_statement(bencher: &mut Bencher) { fn create() -> Connection { let connection = ok!(Connection::open(":memory:")); - ok!(connection.execute( - "CREATE TABLE data (a INTEGER, b REAL, c REAL, d REAL)", - )); + ok!(connection.execute("CREATE TABLE data (a INTEGER, b REAL, c REAL, d REAL)")); connection } fn populate(connection: &Connection, count: usize) { - let mut statement = ok!(connection.prepare( - "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", - )); + let mut statement = + ok!(connection.prepare("INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)")); for i in 0..count { ok!(statement.reset()); ok!(statement.bind(1, i as i64)); diff --git a/src/lib.rs b/src/lib.rs index 1c43685..6c77dd3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -295,7 +295,7 @@ mod statement; pub use connection::Connection; pub use cursor::Cursor; -pub use statement::{Statement, State, Bindable, Readable}; +pub use statement::{Bindable, Readable, State, Statement}; /// Open a connection to a new or existing database. #[inline] diff --git a/tests/lib.rs b/tests/lib.rs index da34dd3..f69cb87 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -10,12 +10,10 @@ macro_rules! ok(($result:expr) => ($result.unwrap())); fn connection_error() { let connection = setup_users(":memory:"); match connection.execute(":)") { - Err(error) => { - assert_eq!( - error.message, - Some(String::from(r#"unrecognized token: ":""#)) - ) - } + Err(error) => assert_eq!( + error.message, + Some(String::from(r#"unrecognized token: ":""#)) + ), _ => unreachable!(), } } @@ -125,12 +123,7 @@ fn cursor_workflow() { ok!(select.bind(&[Value::Integer(42)])); assert_eq!(ok!(select.next()), None); - ok!(insert.bind( - &[ - Value::Integer(42), - Value::String("Bob".to_string()), - ], - )); + ok!(insert.bind(&[Value::Integer(42), Value::String("Bob".to_string())])); assert_eq!(ok!(insert.next()), None); ok!(select.bind(&[Value::Integer(42)]));