diff --git a/src/blob.rs b/src/blob.rs index 5bac455..4361366 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -89,11 +89,7 @@ impl Connection { table.as_ptr(), column.as_ptr(), row, - if read_only { - 0 - } else { - 1 - }, + if read_only { 0 } else { 1 }, &mut blob) }; c.decode_result(rc).map(|_| { @@ -273,7 +269,7 @@ mod test { let mut blob = db.blob_open(DatabaseName::Main, "test", "content", rowid, false).unwrap(); assert_eq!(4, blob.write(b"Clob").unwrap()); assert_eq!(6, blob.write(b"567890xxxxxx").unwrap()); // cannot write past 10 - assert_eq!(0, blob.write(b"5678").unwrap()); // still cannot write past 10 + assert_eq!(0, blob.write(b"5678").unwrap()); // still cannot write past 10 blob.reopen(rowid).unwrap(); blob.close().unwrap(); diff --git a/src/error.rs b/src/error.rs index f0ee5b3..e0aa145 100644 --- a/src/error.rs +++ b/src/error.rs @@ -141,9 +141,7 @@ impl error::Error for Error { "SQLite was compiled or configured for single-threaded use only" } Error::FromSqlConversionFailure(_, _, ref err) => err.description(), - Error::IntegralValueOutOfRange(_, _) => { - "integral value out of range of requested type" - } + Error::IntegralValueOutOfRange(_, _) => "integral value out of range of requested type", Error::Utf8Error(ref err) => err.description(), Error::InvalidParameterName(_) => "invalid parameter name", Error::NulError(ref err) => err.description(), diff --git a/src/functions.rs b/src/functions.rs index 0ab2e1c..3c35b6f 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -228,11 +228,7 @@ impl<'a> Context<'a> { /// types must be identical. pub unsafe fn get_aux(&self, arg: c_int) -> Option<&T> { let p = ffi::sqlite3_get_auxdata(self.ctx, arg) as *mut T; - if p.is_null() { - None - } else { - Some(&*p) - } + if p.is_null() { None } else { Some(&*p) } } } @@ -670,9 +666,10 @@ mod test { }) .unwrap(); - for &(expected, query) in &[("", "SELECT my_concat()"), - ("onetwo", "SELECT my_concat('one', 'two')"), - ("abc", "SELECT my_concat('a', 'b', 'c')")] { + for &(expected, query) in + &[("", "SELECT my_concat()"), + ("onetwo", "SELECT my_concat('one', 'two')"), + ("abc", "SELECT my_concat('a', 'b', 'c')")] { let result: String = db.query_row(query, &[], |r| r.get(0)).unwrap(); assert_eq!(expected, result); } diff --git a/src/lib.rs b/src/lib.rs index a31903f..63b5372 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,12 +103,18 @@ mod named_params; mod error; mod convenient; mod raw_statement; -#[cfg(feature = "load_extension")]mod load_extension_guard; -#[cfg(feature = "trace")]pub mod trace; -#[cfg(feature = "backup")]pub mod backup; -#[cfg(feature = "functions")]pub mod functions; -#[cfg(feature = "blob")]pub mod blob; -#[cfg(feature = "limits")]pub mod limits; +#[cfg(feature = "load_extension")] +mod load_extension_guard; +#[cfg(feature = "trace")] +pub mod trace; +#[cfg(feature = "backup")] +pub mod backup; +#[cfg(feature = "functions")] +pub mod functions; +#[cfg(feature = "blob")] +pub mod blob; +#[cfg(feature = "limits")] +pub mod limits; // Number of cached prepared statements we'll hold on to. const STATEMENT_CACHE_DEFAULT_CAPACITY: usize = 16; @@ -417,10 +423,10 @@ impl Connection { pub fn close(self) -> std::result::Result<(), (Connection, Error)> { self.flush_prepared_statement_cache(); { - let mut db = self.db.borrow_mut(); - db.close() - } - .map_err(move |err| (self, err)) + let mut db = self.db.borrow_mut(); + db.close() + } + .map_err(move |err| (self, err)) } /// Enable loading of SQLite extensions. Strongly consider using `LoadExtensionGuard` @@ -1067,22 +1073,20 @@ impl<'stmt> Rows<'stmt> { /// "streaming iterator". For a more natural interface, consider using `query_map` /// or `query_and_then` instead, which return types that implement `Iterator`. pub fn next<'a>(&'a mut self) -> Option>> { - self.stmt.and_then(|stmt| { - match stmt.stmt.step() { - ffi::SQLITE_ROW => { - Some(Ok(Row { - stmt: stmt, - phantom: PhantomData, - })) - } - ffi::SQLITE_DONE => { - self.reset(); - None - } - code => { - self.reset(); - Some(Err(stmt.conn.decode_result(code).unwrap_err())) - } + self.stmt.and_then(|stmt| match stmt.stmt.step() { + ffi::SQLITE_ROW => { + Some(Ok(Row { + stmt: stmt, + phantom: PhantomData, + })) + } + ffi::SQLITE_DONE => { + self.reset(); + None + } + code => { + self.reset(); + Some(Err(stmt.conn.decode_result(code).unwrap_err())) } }) } @@ -1197,12 +1201,15 @@ impl<'a> ValueRef<'a> { let blob = ffi::sqlite3_column_blob(raw, col); let len = ffi::sqlite3_column_bytes(raw, col); - assert!(len >= 0, "unexpected negative return from sqlite3_column_bytes"); + assert!(len >= 0, + "unexpected negative return from sqlite3_column_bytes"); if len > 0 { - assert!(!blob.is_null(), "unexpected SQLITE_BLOB column type with NULL data"); + assert!(!blob.is_null(), + "unexpected SQLITE_BLOB column type with NULL data"); ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize)) } else { - // The return value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. + // The return value from sqlite3_column_blob() for a zero-length BLOB + // is a NULL pointer. ValueRef::Blob(&[]) } } diff --git a/src/types/chrono.rs b/src/types/chrono.rs index b0254ce..1503726 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -5,7 +5,7 @@ use std::borrow::Cow; use self::chrono::{NaiveDate, NaiveTime, NaiveDateTime, DateTime, TimeZone, UTC, Local}; -use ::Result; +use Result; use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; /// ISO 8601 calendar date without timezone => "YYYY-MM-DD" diff --git a/src/types/serde_json.rs b/src/types/serde_json.rs index 2e943ef..c710a81 100644 --- a/src/types/serde_json.rs +++ b/src/types/serde_json.rs @@ -3,7 +3,7 @@ extern crate serde_json; use self::serde_json::Value; -use ::Result; +use Result; use types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; /// Serialize JSON `Value` to text. diff --git a/src/types/to_sql.rs b/src/types/to_sql.rs index 0e708f2..0e4d754 100644 --- a/src/types/to_sql.rs +++ b/src/types/to_sql.rs @@ -1,5 +1,5 @@ use super::{Null, Value, ValueRef}; -use ::Result; +use Result; /// `ToSqlOutput` represents the possible output types for implementors of the `ToSql` trait. #[derive(Clone,Debug,PartialEq)] diff --git a/src/types/value_ref.rs b/src/types/value_ref.rs index 96a7641..e90c16f 100644 --- a/src/types/value_ref.rs +++ b/src/types/value_ref.rs @@ -1,4 +1,4 @@ -use ::types::{FromSqlError, FromSqlResult}; +use types::{FromSqlError, FromSqlResult}; use super::{Value, Type}; /// A non-owning [dynamic type value](http://sqlite.org/datatype3.html). Typically the diff --git a/tests/config_log.rs b/tests/config_log.rs index e0167bd..83a660e 100644 --- a/tests/config_log.rs +++ b/tests/config_log.rs @@ -1,7 +1,8 @@ //! This file contains unit tests for rusqlite::trace::config_log. This function affects //! SQLite process-wide and so is not safe to run as a normal #[test] in the library. -#[macro_use] extern crate lazy_static; +#[macro_use] +extern crate lazy_static; extern crate libc; extern crate rusqlite;