From b3b10acd2a019948f19aa08cfb4f5edd9165dea7 Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Wed, 23 Aug 2017 06:06:04 +0200 Subject: [PATCH] Fix styles --- README.md | 12 ++---------- benches/lib.rs | 24 ++++++------------------ src/lib.rs | 35 +++++++++++++++++++---------------- 3 files changed, 27 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 6a6a7d0..85d5d37 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,7 @@ the previous technique: use sqlite::State; let mut statement = connection - .prepare( - " - SELECT * FROM users WHERE age > ? - ", - ) + .prepare("SELECT * FROM users WHERE age > ?") .unwrap(); statement.bind(1, 50).unwrap(); @@ -62,11 +58,7 @@ statement providing the concept of row and featuring all-at-once binding: use sqlite::Value; let mut cursor = connection - .prepare( - " - SELECT * FROM users WHERE age > ? - ", - ) + .prepare("SELECT * FROM users WHERE age > ?") .unwrap() .cursor(); diff --git a/benches/lib.rs b/benches/lib.rs index 0063a11..911afe5 100644 --- a/benches/lib.rs +++ b/benches/lib.rs @@ -14,9 +14,7 @@ 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 > ? - ", + "SELECT * FROM data WHERE a > ? AND b > ?", )).cursor(); bencher.iter(|| { @@ -33,9 +31,7 @@ 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 > ? - ", + "SELECT * FROM data WHERE a > ? AND b > ?", )); bencher.iter(|| { @@ -53,9 +49,7 @@ fn read_statement(bencher: &mut Bencher) { fn write_cursor(bencher: &mut Bencher) { let connection = create(); let mut cursor = ok!(connection.prepare( - " - INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?) - ", + "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", )).cursor(); bencher.iter(|| { @@ -70,9 +64,7 @@ fn write_cursor(bencher: &mut Bencher) { fn write_statement(bencher: &mut Bencher) { let connection = create(); let mut statement = ok!(connection.prepare( - " - INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?) - ", + "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", )); bencher.iter(|| { @@ -88,18 +80,14 @@ 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) - ", + "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 (?, ?, ?, ?) - ", + "INSERT INTO data (a, b, c, d) VALUES (?, ?, ?, ?)", )); for i in 0..count { ok!(statement.reset()); diff --git a/src/lib.rs b/src/lib.rs index f9fe539..381acf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,11 +58,7 @@ //! # .unwrap(); //! //! let mut statement = connection -//! .prepare( -//! " -//! SELECT * FROM users WHERE age > ? -//! ", -//! ) +//! .prepare("SELECT * FROM users WHERE age > ?") //! .unwrap(); //! //! statement.bind(1, 50).unwrap(); @@ -90,11 +86,7 @@ //! # .unwrap(); //! //! let mut cursor = connection -//! .prepare( -//! " -//! SELECT * FROM users WHERE age > ? -//! ", -//! ) +//! .prepare("SELECT * FROM users WHERE age > ?") //! .unwrap() //! .cursor(); //! @@ -114,24 +106,35 @@ extern crate sqlite3_sys as ffi; use std::{error, fmt}; macro_rules! raise( - ($message:expr) => (return Err(::Error { code: None, message: Some($message.to_string()) })); + ($message:expr) => ( + return Err(::Error { + code: None, + message: Some($message.to_string()), + }) + ); ); macro_rules! error( ($connection:expr, $code:expr) => (match ::last_error($connection) { Some(error) => return Err(error), - _ => return Err(::Error { code: Some($code as isize), message: None }), + _ => return Err(::Error { + code: Some($code as isize), + message: None, + }), }); ); macro_rules! ok( ($connection:expr, $result:expr) => (match $result { - ::ffi::SQLITE_OK => {}, + ::ffi::SQLITE_OK => {} code => error!($connection, code), }); ($result:expr) => (match $result { - ::ffi::SQLITE_OK => {}, - code => return Err(::Error { code: Some(code as isize), message: None }), + ::ffi::SQLITE_OK => {} + code => return Err(::Error { + code: Some(code as isize), + message: None, + }), }); ); @@ -151,7 +154,7 @@ macro_rules! path_to_cstr( Some(path) => match ::std::ffi::CString::new(path) { Ok(string) => string, _ => raise!("failed to process a path"), - }, + } _ => raise!("failed to process a path"), }); );