diff --git a/src/lib.rs b/src/lib.rs index d8f06d2..3530cf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,7 +142,7 @@ fn str_to_cstring(s: &str) -> Result { } fn path_to_cstring(p: &Path) -> Result { - let s = try!(p.to_str().ok_or(Error::InvalidPath(p.to_owned()))); + let s = try!(p.to_str().ok_or_else(|| Error::InvalidPath(p.to_owned()))); str_to_cstring(s) } @@ -588,12 +588,12 @@ bitflags! { const SQLITE_OPEN_READ_ONLY = ffi::SQLITE_OPEN_READONLY; const SQLITE_OPEN_READ_WRITE = ffi::SQLITE_OPEN_READWRITE; const SQLITE_OPEN_CREATE = ffi::SQLITE_OPEN_CREATE; - const SQLITE_OPEN_URI = 0x00000040; - const SQLITE_OPEN_MEMORY = 0x00000080; + const SQLITE_OPEN_URI = 0x0000_0040; + const SQLITE_OPEN_MEMORY = 0x0000_0080; const SQLITE_OPEN_NO_MUTEX = ffi::SQLITE_OPEN_NOMUTEX; const SQLITE_OPEN_FULL_MUTEX = ffi::SQLITE_OPEN_FULLMUTEX; - const SQLITE_OPEN_SHARED_CACHE = 0x00020000; - const SQLITE_OPEN_PRIVATE_CACHE = 0x00040000; + const SQLITE_OPEN_SHARED_CACHE = 0x0002_0000; + const SQLITE_OPEN_PRIVATE_CACHE = 0x0004_0000; } } @@ -639,7 +639,7 @@ fn ensure_valid_sqlite_version() { let version_number = version_number(); // Check our hard floor. - if version_number < 3006008 { + if version_number < 3_006_008 { panic!("rusqlite requires SQLite 3.6.8 or newer"); } @@ -692,7 +692,7 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> { // will fail if someone else has already initialized SQLite even if they initialized it // safely. That's not ideal either, which is why we expose bypass_sqlite_initialization // above. - if version_number() >= 3007000 { + if version_number() >= 3_007_000 { const SQLITE_SINGLETHREADED_MUTEX_MAGIC: usize = 8; let is_singlethreaded = unsafe { let mutex_ptr = ffi::sqlite3_mutex_alloc(0); @@ -738,9 +738,9 @@ impl InnerConnection { // Replicate the check for sane open flags from SQLite, because the check in SQLite itself // wasn't added until version 3.7.3. - debug_assert!(1 << OpenFlags::SQLITE_OPEN_READ_ONLY.bits == 0x02); - debug_assert!(1 << OpenFlags::SQLITE_OPEN_READ_WRITE.bits == 0x04); - debug_assert!(1 << (OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE).bits == 0x40); + debug_assert_eq!(1 << OpenFlags::SQLITE_OPEN_READ_ONLY.bits, 0x02); + debug_assert_eq!(1 << OpenFlags::SQLITE_OPEN_READ_WRITE.bits, 0x04); + debug_assert_eq!(1 << (OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE).bits, 0x40); if (1 << (flags.bits & 0x7)) & 0x46 == 0 { return Err(Error::SqliteFailure(ffi::Error::new(ffi::SQLITE_MISUSE), None)); } diff --git a/src/statement.rs b/src/statement.rs index 8885ec1..2674c32 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -368,7 +368,7 @@ impl<'conn> Statement<'conn> { } fn bind_parameters(&mut self, params: &[&ToSql]) -> Result<()> { - assert!(params.len() as c_int == self.stmt.bind_parameter_count(), + assert_eq!(params.len() as c_int, self.stmt.bind_parameter_count(), "incorrect number of parameters to query(): expected {}, got {}", self.stmt.bind_parameter_count(), params.len()); diff --git a/src/types/chrono.rs b/src/types/chrono.rs index 4d0b763..3c566e5 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -91,7 +91,7 @@ impl ToSql for DateTime { } } -/// RFC3339 ("YYYY-MM-DDTHH:MM:SS.SSS[+-]HH:MM") into DateTime. +/// RFC3339 ("YYYY-MM-DDTHH:MM:SS.SSS[+-]HH:MM") into `DateTime`. impl FromSql for DateTime { fn column_result(value: ValueRef) -> FromSqlResult { { @@ -120,7 +120,7 @@ impl FromSql for DateTime { } } -/// RFC3339 ("YYYY-MM-DDTHH:MM:SS.SSS[+-]HH:MM") into DateTime. +/// RFC3339 ("YYYY-MM-DDTHH:MM:SS.SSS[+-]HH:MM") into `DateTime`. impl FromSql for DateTime { fn column_result(value: ValueRef) -> FromSqlResult { let utc_dt = try!(DateTime::::column_result(value)); diff --git a/tests/config_log.rs b/tests/config_log.rs index 6ae83d1..cd9a25c 100644 --- a/tests/config_log.rs +++ b/tests/config_log.rs @@ -1,4 +1,4 @@ -//! This file contains unit tests for rusqlite::trace::config_log. This function affects +//! 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. #[cfg(feature = "trace")]