diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 2321c91..dee18af 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -74,11 +74,13 @@ mod build_bundled { .flag("-DSQLITE_THREADSAFE=1") .flag("-DSQLITE_USE_URI") .flag("-DHAVE_USLEEP=1"); - // Older versions of visual studio don't support c99 (including isnan), which causes a - // build failure when the linker fails to find the `isnan` function. `sqlite` provides its - // own implmentation, using the fact that x != x when x is NaN. + // Older versions of visual studio don't support c99 (including isnan), which + // causes a build failure when the linker fails to find the `isnan` + // function. `sqlite` provides its own implmentation, using the fact + // that x != x when x is NaN. // - // There may be other platforms that don't support `isnan`, they should be tested for here. + // There may be other platforms that don't support `isnan`, they should be + // tested for here. if cfg!(target_env = "msvc") { use self::cc::windows_registry::{find_vs_version, VsVers}; let vs_has_nan = match find_vs_version() { diff --git a/src/error.rs b/src/error.rs index abd4669..827c781 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,5 @@ -use crate::types::Type; use crate::types::FromSqlError; +use crate::types::Type; use crate::{errmsg_to_string, ffi}; use std::error; use std::fmt; @@ -162,7 +162,8 @@ const UNKNOWN_COLUMN: usize = std::usize::MAX; /// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`. impl From for Error { fn from(err: FromSqlError) -> Error { - // The error type requires index and type fields, but they aren't known in this context. + // The error type requires index and type fields, but they aren't known in this + // context. match err { FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val), #[cfg(feature = "i128_blob")] @@ -190,20 +191,24 @@ impl fmt::Display for Error { f, "SQLite was compiled or configured for single-threaded use only" ), - Error::FromSqlConversionFailure(i, ref t, ref err) => if i != UNKNOWN_COLUMN { - write!( - f, - "Conversion error from type {} at index: {}, {}", - t, i, err - ) - } else { - err.fmt(f) - }, - Error::IntegralValueOutOfRange(col, val) => if col != UNKNOWN_COLUMN { - write!(f, "Integer {} out of range at index {}", val, col) - } else { - write!(f, "Integer {} out of range", val) - }, + Error::FromSqlConversionFailure(i, ref t, ref err) => { + if i != UNKNOWN_COLUMN { + write!( + f, + "Conversion error from type {} at index: {}, {}", + t, i, err + ) + } else { + err.fmt(f) + } + } + Error::IntegralValueOutOfRange(col, val) => { + if col != UNKNOWN_COLUMN { + write!(f, "Integer {} out of range at index {}", val, col) + } else { + write!(f, "Integer {} out of range", val) + } + } Error::Utf8Error(ref err) => err.fmt(f), Error::NulError(ref err) => err.fmt(f), Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name), diff --git a/src/hooks.rs b/src/hooks.rs index 946407a..e8efe76 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -236,8 +236,8 @@ fn free_boxed_hook(p: *mut c_void) { mod test { use super::Action; use crate::Connection; - use std::sync::atomic::{AtomicBool, Ordering}; use lazy_static::lazy_static; + use std::sync::atomic::{AtomicBool, Ordering}; #[test] fn test_commit_hook() { diff --git a/src/trace.rs b/src/trace.rs index d6f3969..572b21f 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -122,9 +122,9 @@ impl Connection { #[cfg(test)] mod test { + use lazy_static::lazy_static; use std::sync::Mutex; use std::time::Duration; - use lazy_static::lazy_static; use crate::Connection; diff --git a/tests/config_log.rs b/tests/config_log.rs index aa90b94..0c28bdf 100644 --- a/tests/config_log.rs +++ b/tests/config_log.rs @@ -4,9 +4,9 @@ #[cfg(feature = "trace")] fn main() { + use lazy_static::lazy_static; use std::os::raw::c_int; use std::sync::Mutex; - use lazy_static::lazy_static; lazy_static! { static ref LOGS_RECEIVED: Mutex> = Mutex::new(Vec::new());