From f9099ba02b6a516aa3f0fd863b40ffd8089cc242 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:00:12 +0100 Subject: [PATCH 1/7] Add workspace declaration --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 504d565..fb288ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,9 @@ maintenance = { status = "actively-developed" } [lib] name = "rusqlite" +[workspace] +members = ["libsqlite3-sys"] + [features] load_extension = [] # hot-backup interface: 3.6.11 (2009-02-18) From 62d5ffe67826b6568b7faa93496771071352bc6f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:04:46 +0100 Subject: [PATCH 2/7] Fix some enum representation --- libsqlite3-sys/src/error.rs | 7 ++++--- libsqlite3-sys/src/lib.rs | 36 ++++++++++++++++++++---------------- src/hooks.rs | 7 ++++--- src/session.rs | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index bf1367f..9e318e0 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -115,9 +115,10 @@ impl error::Error for Error { } // Result codes. -// Note: These are not public because our bindgen bindings export whichever constants are present -// in the current version of SQLite. We repeat them here so we don't have to worry about which -// version of SQLite added which constants, and we only use them to implement code_to_str below. +// Note: These are not public because our bindgen bindings export whichever +// constants are present in the current version of SQLite. We repeat them here +// so we don't have to worry about which version of SQLite added which +// constants, and we only use them to implement code_to_str below. const SQLITE_NOTICE: c_int = 27; const SQLITE_WARNING: c_int = 28; diff --git a/libsqlite3-sys/src/lib.rs b/libsqlite3-sys/src/lib.rs index 0e76759..795d604 100644 --- a/libsqlite3-sys/src/lib.rs +++ b/libsqlite3-sys/src/lib.rs @@ -16,32 +16,36 @@ pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type { } /// Run-Time Limit Categories -#[repr(C)] +#[repr(i32)] pub enum Limit { /// The maximum size of any string or BLOB or table row, in bytes. - SQLITE_LIMIT_LENGTH = SQLITE_LIMIT_LENGTH as isize, + SQLITE_LIMIT_LENGTH = SQLITE_LIMIT_LENGTH, /// The maximum length of an SQL statement, in bytes. - SQLITE_LIMIT_SQL_LENGTH = SQLITE_LIMIT_SQL_LENGTH as isize, - /// The maximum number of columns in a table definition or in the result set of a SELECT - /// or the maximum number of columns in an index or in an ORDER BY or GROUP BY clause. - SQLITE_LIMIT_COLUMN = SQLITE_LIMIT_COLUMN as isize, + SQLITE_LIMIT_SQL_LENGTH = SQLITE_LIMIT_SQL_LENGTH, + /// The maximum number of columns in a table definition or in the result set + /// of a SELECT or the maximum number of columns in an index or in an + /// ORDER BY or GROUP BY clause. + SQLITE_LIMIT_COLUMN = SQLITE_LIMIT_COLUMN, /// The maximum depth of the parse tree on any expression. - SQLITE_LIMIT_EXPR_DEPTH = SQLITE_LIMIT_EXPR_DEPTH as isize, + SQLITE_LIMIT_EXPR_DEPTH = SQLITE_LIMIT_EXPR_DEPTH, /// The maximum number of terms in a compound SELECT statement. - SQLITE_LIMIT_COMPOUND_SELECT = SQLITE_LIMIT_COMPOUND_SELECT as isize, - /// The maximum number of instructions in a virtual machine program used to implement an SQL statement. - SQLITE_LIMIT_VDBE_OP = SQLITE_LIMIT_VDBE_OP as isize, + SQLITE_LIMIT_COMPOUND_SELECT = SQLITE_LIMIT_COMPOUND_SELECT, + /// The maximum number of instructions in a virtual machine program used to + /// implement an SQL statement. + SQLITE_LIMIT_VDBE_OP = SQLITE_LIMIT_VDBE_OP, /// The maximum number of arguments on a function. - SQLITE_LIMIT_FUNCTION_ARG = SQLITE_LIMIT_FUNCTION_ARG as isize, + SQLITE_LIMIT_FUNCTION_ARG = SQLITE_LIMIT_FUNCTION_ARG, /// The maximum number of attached databases. - SQLITE_LIMIT_ATTACHED = SQLITE_LIMIT_ATTACHED as isize, - /// The maximum length of the pattern argument to the LIKE or GLOB operators. - SQLITE_LIMIT_LIKE_PATTERN_LENGTH = SQLITE_LIMIT_LIKE_PATTERN_LENGTH as isize, + SQLITE_LIMIT_ATTACHED = SQLITE_LIMIT_ATTACHED, + /// The maximum length of the pattern argument to the LIKE or GLOB + /// operators. + SQLITE_LIMIT_LIKE_PATTERN_LENGTH = SQLITE_LIMIT_LIKE_PATTERN_LENGTH, /// The maximum index number of any parameter in an SQL statement. - SQLITE_LIMIT_VARIABLE_NUMBER = SQLITE_LIMIT_VARIABLE_NUMBER as isize, + SQLITE_LIMIT_VARIABLE_NUMBER = SQLITE_LIMIT_VARIABLE_NUMBER, /// The maximum depth of recursion for triggers. SQLITE_LIMIT_TRIGGER_DEPTH = 10, - /// The maximum number of auxiliary worker threads that a single prepared statement may start. + /// The maximum number of auxiliary worker threads that a single prepared + /// statement may start. SQLITE_LIMIT_WORKER_THREADS = 11, } diff --git a/src/hooks.rs b/src/hooks.rs index 9397ca0..3ca3345 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -11,11 +11,12 @@ use crate::{Connection, InnerConnection}; /// Action Codes #[derive(Clone, Copy, Debug, PartialEq)] +#[repr(i32)] pub enum Action { UNKNOWN = -1, - SQLITE_DELETE = ffi::SQLITE_DELETE as isize, - SQLITE_INSERT = ffi::SQLITE_INSERT as isize, - SQLITE_UPDATE = ffi::SQLITE_UPDATE as isize, + SQLITE_DELETE = ffi::SQLITE_DELETE, + SQLITE_INSERT = ffi::SQLITE_INSERT, + SQLITE_UPDATE = ffi::SQLITE_UPDATE, } impl From for Action { diff --git a/src/session.rs b/src/session.rs index 6c92aea..2fad29a 100644 --- a/src/session.rs +++ b/src/session.rs @@ -608,14 +608,15 @@ impl Connection { } /// Constants passed to the conflict handler +#[repr(i32)] #[derive(Debug, PartialEq)] pub enum ConflictType { UNKNOWN = -1, - SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA as isize, - SQLITE_CHANGESET_NOTFOUND = ffi::SQLITE_CHANGESET_NOTFOUND as isize, - SQLITE_CHANGESET_CONFLICT = ffi::SQLITE_CHANGESET_CONFLICT as isize, - SQLITE_CHANGESET_CONSTRAINT = ffi::SQLITE_CHANGESET_CONSTRAINT as isize, - SQLITE_CHANGESET_FOREIGN_KEY = ffi::SQLITE_CHANGESET_FOREIGN_KEY as isize, + SQLITE_CHANGESET_DATA = ffi::SQLITE_CHANGESET_DATA, + SQLITE_CHANGESET_NOTFOUND = ffi::SQLITE_CHANGESET_NOTFOUND, + SQLITE_CHANGESET_CONFLICT = ffi::SQLITE_CHANGESET_CONFLICT, + SQLITE_CHANGESET_CONSTRAINT = ffi::SQLITE_CHANGESET_CONSTRAINT, + SQLITE_CHANGESET_FOREIGN_KEY = ffi::SQLITE_CHANGESET_FOREIGN_KEY, } impl From for ConflictType { fn from(code: i32) -> ConflictType { @@ -631,11 +632,12 @@ impl From for ConflictType { } /// Constants returned by the conflict handler +#[repr(i32)] #[derive(Debug, PartialEq)] pub enum ConflictAction { - SQLITE_CHANGESET_OMIT = ffi::SQLITE_CHANGESET_OMIT as isize, - SQLITE_CHANGESET_REPLACE = ffi::SQLITE_CHANGESET_REPLACE as isize, - SQLITE_CHANGESET_ABORT = ffi::SQLITE_CHANGESET_ABORT as isize, + SQLITE_CHANGESET_OMIT = ffi::SQLITE_CHANGESET_OMIT, + SQLITE_CHANGESET_REPLACE = ffi::SQLITE_CHANGESET_REPLACE, + SQLITE_CHANGESET_ABORT = ffi::SQLITE_CHANGESET_ABORT, } unsafe extern "C" fn call_filter(p_ctx: *mut c_void, tbl_str: *const c_char) -> c_int From 4c4578851b836fcd7a6768d1e9fbf318b41c8e7f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:08:04 +0100 Subject: [PATCH 3/7] Remove needless lifetimes --- src/cache.rs | 2 +- src/context.rs | 2 +- src/lib.rs | 2 +- src/session.rs | 2 +- src/statement.rs | 10 +++------- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 8dc3912..da128a8 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -33,7 +33,7 @@ impl Connection { /// /// Will return `Err` if `sql` cannot be converted to a C-compatible string /// or if the underlying SQLite call fails. - pub fn prepare_cached<'a>(&'a self, sql: &str) -> Result> { + pub fn prepare_cached(&self, sql: &str) -> Result> { self.cache.get(self, sql) } diff --git a/src/context.rs b/src/context.rs index 71a5218..a7bb468 100644 --- a/src/context.rs +++ b/src/context.rs @@ -12,7 +12,7 @@ use crate::types::{ToSqlOutput, ValueRef}; #[cfg(feature = "array")] use crate::vtab::array::{free_array, ARRAY_TYPE}; -pub(crate) unsafe fn set_result<'a>(ctx: *mut sqlite3_context, result: &ToSqlOutput<'a>) { +pub(crate) unsafe fn set_result(ctx: *mut sqlite3_context, result: &ToSqlOutput<'_>) { let value = match *result { ToSqlOutput::Borrowed(v) => v, ToSqlOutput::Owned(ref v) => ValueRef::from(v), diff --git a/src/lib.rs b/src/lib.rs index ac61236..1cc4a1d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -567,7 +567,7 @@ impl Connection { /// /// Will return `Err` if `sql` cannot be converted to a C-compatible string /// or if the underlying SQLite call fails. - pub fn prepare<'a>(&'a self, sql: &str) -> Result> { + pub fn prepare(&self, sql: &str) -> Result> { self.db.borrow_mut().prepare(self, sql) } diff --git a/src/session.rs b/src/session.rs index 2fad29a..06ad8a7 100644 --- a/src/session.rs +++ b/src/session.rs @@ -258,7 +258,7 @@ impl Changeset { } /// Create an iterator to traverse a changeset - pub fn iter<'changeset>(&'changeset self) -> Result> { + pub fn iter(&self) -> Result> { let mut it: *mut ffi::sqlite3_changeset_iter = unsafe { mem::uninitialized() }; check!(unsafe { ffi::sqlite3changeset_start(&mut it, self.n, self.cs) }); Ok(ChangesetIter { diff --git a/src/statement.rs b/src/statement.rs index 439a9e9..1d22d52 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -186,7 +186,7 @@ impl<'conn> Statement<'conn> { /// ## Failure /// /// Will return `Err` if binding parameters fails. - pub fn query<'a, P>(&'a mut self, params: P) -> Result> + pub fn query

(&mut self, params: P) -> Result> where P: IntoIterator, P::Item: ToSql, @@ -263,7 +263,7 @@ impl<'conn> Statement<'conn> { /// ## Failure /// /// Will return `Err` if binding parameters fails. - pub fn query_map<'a, T, P, F>(&'a mut self, params: P, f: F) -> Result> + pub fn query_map(&mut self, params: P, f: F) -> Result> where P: IntoIterator, P::Item: ToSql, @@ -319,11 +319,7 @@ impl<'conn> Statement<'conn> { /// # Failure /// /// Will return `Err` if binding parameters fails. - pub fn query_and_then<'a, T, E, P, F>( - &'a mut self, - params: P, - f: F, - ) -> Result> + pub fn query_and_then(&mut self, params: P, f: F) -> Result> where P: IntoIterator, P::Item: ToSql, From be98290bbdc6fc7b38f359034d40c7ad9bb98712 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:09:00 +0100 Subject: [PATCH 4/7] Replace assert! by assert_eq! --- src/functions.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 81372e1..a94b9a7 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -523,7 +523,7 @@ mod test { use crate::{Connection, Error, Result, NO_PARAMS}; fn half(ctx: &Context<'_>) -> Result { - assert!(ctx.len() == 1, "called with unexpected number of arguments"); + assert_eq!(ctx.len(), 1, "called with unexpected number of arguments"); let value = ctx.get::(0)?; Ok(value / 2f64) } @@ -553,7 +553,7 @@ mod test { // (https://www.sqlite.org/c3ref/get_auxdata.html) to avoid recompiling the regular // expression multiple times within one query. fn regexp_with_auxilliary(ctx: &Context<'_>) -> Result { - assert!(ctx.len() == 2, "called with unexpected number of arguments"); + assert_eq!(ctx.len(), 2, "called with unexpected number of arguments"); let saved_re: Option<&Regex> = ctx.get_aux(0)?; let new_re = match saved_re { @@ -634,7 +634,7 @@ mod test { // until the function is removed. let mut cached_regexes = HashMap::new(); db.create_scalar_function("regexp", 2, true, move |ctx| { - assert!(ctx.len() == 2, "called with unexpected number of arguments"); + assert_eq!(ctx.len(), 2, "called with unexpected number of arguments"); let regex_s = ctx.get::(0)?; let entry = cached_regexes.entry(regex_s.clone()); From 20fed1956edd75cd17e4c896fb40c98105c2cc98 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:10:08 +0100 Subject: [PATCH 5/7] Rename some static variables --- src/hooks.rs | 18 +++++++++--------- src/session.rs | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/hooks.rs b/src/hooks.rs index 3ca3345..3131462 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -243,15 +243,15 @@ mod test { let db = Connection::open_in_memory().unwrap(); lazy_static! { - static ref called: AtomicBool = AtomicBool::new(false); + static ref CALLED: AtomicBool = AtomicBool::new(false); } db.commit_hook(Some(|| { - called.store(true, Ordering::Relaxed); + CALLED.store(true, Ordering::Relaxed); false })); db.execute_batch("BEGIN; CREATE TABLE foo (t TEXT); COMMIT;") .unwrap(); - assert!(called.load(Ordering::Relaxed)); + assert!(CALLED.load(Ordering::Relaxed)); } #[test] @@ -272,14 +272,14 @@ mod test { let db = Connection::open_in_memory().unwrap(); lazy_static! { - static ref called: AtomicBool = AtomicBool::new(false); + static ref CALLED: AtomicBool = AtomicBool::new(false); } db.rollback_hook(Some(|| { - called.store(true, Ordering::Relaxed); + CALLED.store(true, Ordering::Relaxed); })); db.execute_batch("BEGIN; CREATE TABLE foo (t TEXT); ROLLBACK;") .unwrap(); - assert!(called.load(Ordering::Relaxed)); + assert!(CALLED.load(Ordering::Relaxed)); } #[test] @@ -287,17 +287,17 @@ mod test { let db = Connection::open_in_memory().unwrap(); lazy_static! { - static ref called: AtomicBool = AtomicBool::new(false); + static ref CALLED: AtomicBool = AtomicBool::new(false); } db.update_hook(Some(|action, db: &str, tbl: &str, row_id| { assert_eq!(Action::SQLITE_INSERT, action); assert_eq!("main", db); assert_eq!("foo", tbl); assert_eq!(1, row_id); - called.store(true, Ordering::Relaxed); + CALLED.store(true, Ordering::Relaxed); })); db.execute_batch("CREATE TABLE foo (t TEXT)").unwrap(); db.execute_batch("INSERT INTO foo VALUES ('lisa')").unwrap(); - assert!(called.load(Ordering::Relaxed)); + assert!(CALLED.load(Ordering::Relaxed)); } } diff --git a/src/session.rs b/src/session.rs index 06ad8a7..70a9f53 100644 --- a/src/session.rs +++ b/src/session.rs @@ -797,19 +797,19 @@ mod test { .unwrap(); lazy_static! { - static ref called: AtomicBool = AtomicBool::new(false); + static ref CALLED: AtomicBool = AtomicBool::new(false); } db.apply( &changeset, None:: bool>, |_conflict_type, _item| { - called.store(true, Ordering::Relaxed); + CALLED.store(true, Ordering::Relaxed); ConflictAction::SQLITE_CHANGESET_OMIT }, ) .unwrap(); - assert!(!called.load(Ordering::Relaxed)); + assert!(!CALLED.load(Ordering::Relaxed)); let check = db .query_row("SELECT 1 FROM foo WHERE t = ?", &["bar"], |row| { row.get::<_, i32>(0) @@ -822,7 +822,7 @@ mod test { &changeset, None:: bool>, |conflict_type, item| { - called.store(true, Ordering::Relaxed); + CALLED.store(true, Ordering::Relaxed); assert_eq!(ConflictType::SQLITE_CHANGESET_CONFLICT, conflict_type); let conflict = item.conflict(0).unwrap(); assert_eq!(Ok("bar"), conflict.as_str()); @@ -830,7 +830,7 @@ mod test { }, ) .unwrap(); - assert!(called.load(Ordering::Relaxed)); + assert!(CALLED.load(Ordering::Relaxed)); } #[test] From f695f185c2fff1011248a106304de16eee5fe426 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:10:58 +0100 Subject: [PATCH 6/7] Fix/suppress warning 'deprecated' --- src/types/from_sql.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index 79b477c..46539a4 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -60,6 +60,7 @@ impl Error for FromSqlError { } #[allow(clippy::match_same_arms)] + #[allow(deprecated)] fn cause(&self) -> Option<&dyn Error> { match *self { FromSqlError::Other(ref err) => err.cause(), From 8862b17340040eafc92f792d22381fe648ef6e6f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Feb 2019 11:37:26 +0100 Subject: [PATCH 7/7] Fix clippy warnings --- src/lib.rs | 6 ++---- src/limits.rs | 4 ++-- src/statement.rs | 3 ++- src/types/from_sql.rs | 6 +++--- src/types/mod.rs | 1 + src/types/time.rs | 8 ++++---- src/vtab/array.rs | 2 +- src/vtab/csvtab.rs | 2 +- src/vtab/series.rs | 2 +- tests/vtab.rs | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1cc4a1d..7e7153a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1247,11 +1247,9 @@ mod test { let tx2 = db2.transaction().unwrap(); // SELECT first makes sqlite lock with a shared lock - let _ = tx1 - .query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ()) + tx1.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ()) .unwrap(); - let _ = tx2 - .query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ()) + tx2.query_row("SELECT x FROM foo LIMIT 1", NO_PARAMS, |_| ()) .unwrap(); tx1.execute("INSERT INTO foo VALUES(?1)", &[1]).unwrap(); diff --git a/src/limits.rs b/src/limits.rs index cbe9beb..cbb5e61 100644 --- a/src/limits.rs +++ b/src/limits.rs @@ -57,13 +57,13 @@ mod test { assert_eq!(99, db.limit(Limit::SQLITE_LIMIT_VARIABLE_NUMBER)); // SQLITE_LIMIT_TRIGGER_DEPTH was added in SQLite 3.6.18. - if crate::version_number() >= 3006018 { + if crate::version_number() >= 3_006_018 { db.set_limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH, 32); assert_eq!(32, db.limit(Limit::SQLITE_LIMIT_TRIGGER_DEPTH)); } // SQLITE_LIMIT_WORKER_THREADS was added in SQLite 3.8.7. - if crate::version_number() >= 3008007 { + if crate::version_number() >= 3_008_007 { db.set_limit(Limit::SQLITE_LIMIT_WORKER_THREADS, 2); assert_eq!(2, db.limit(Limit::SQLITE_LIMIT_WORKER_THREADS)); } diff --git a/src/statement.rs b/src/statement.rs index 1d22d52..562817c 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -854,6 +854,7 @@ mod test { assert_eq!(1, doubled_id); // second row should be Err + #[allow(clippy::match_wild_err_arm)] match rows.next().unwrap() { Ok(_) => panic!("invalid Ok"), Err(Error::SqliteSingleThreadedMode) => (), @@ -1038,7 +1039,7 @@ mod test { use std::collections::BTreeSet; let data: BTreeSet = ["one", "two", "three"] - .into_iter() + .iter() .map(|s| s.to_string()) .collect(); db.query_row("SELECT ?1, ?2, ?3", &data, |row| row.get::<_, String>(0)) diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index 46539a4..c917b7a 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -232,11 +232,11 @@ mod test { check_ranges::(&db, &[-32769, 32768], &[-32768, -1, 0, 1, 32767]); check_ranges::( &db, - &[-2147483649, 2147483648], - &[-2147483648, -1, 0, 1, 2147483647], + &[-2_147_483_649, 2_147_483_648], + &[-2_147_483_648, -1, 0, 1, 2_147_483_647], ); check_ranges::(&db, &[-2, -1, 256], &[0, 1, 255]); check_ranges::(&db, &[-2, -1, 65536], &[0, 1, 65535]); - check_ranges::(&db, &[-2, -1, 4294967296], &[0, 1, 4294967295]); + check_ranges::(&db, &[-2, -1, 4_294_967_296], &[0, 1, 4_294_967_295]); } } diff --git a/src/types/mod.rs b/src/types/mod.rs index ceb16b8..508b273 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -223,6 +223,7 @@ mod test { } #[test] + #[allow(clippy::cyclomatic_complexity)] fn test_mismatched_types() { fn is_invalid_column_type(err: Error) -> bool { match err { diff --git a/src/types/time.rs b/src/types/time.rs index 608635f..ed45a89 100644 --- a/src/types/time.rs +++ b/src/types/time.rs @@ -54,10 +54,10 @@ mod test { ts_vec.push(time::Timespec::new(10_000, 0)); //January 1, 1970 2:46:40 AM ts_vec.push(time::Timespec::new(10_000, 1000)); //January 1, 1970 2:46:40 AM (and one microsecond) - ts_vec.push(time::Timespec::new(1500391124, 1_000_000)); //July 18, 2017 - ts_vec.push(time::Timespec::new(2000000000, 2_000_000)); //May 18, 2033 - ts_vec.push(time::Timespec::new(3000000000, 999_999_999)); //January 24, 2065 - ts_vec.push(time::Timespec::new(10000000000, 0)); //November 20, 2286 + ts_vec.push(time::Timespec::new(1_500_391_124, 1_000_000)); //July 18, 2017 + ts_vec.push(time::Timespec::new(2_000_000_000, 2_000_000)); //May 18, 2033 + ts_vec.push(time::Timespec::new(3_000_000_000, 999_999_999)); //January 24, 2065 + ts_vec.push(time::Timespec::new(10_000_000_000, 0)); //November 20, 2286 for ts in ts_vec { db.execute("INSERT INTO foo(t) VALUES (?)", &[&ts]).unwrap(); diff --git a/src/vtab/array.rs b/src/vtab/array.rs index f83f44e..1b4bd46 100644 --- a/src/vtab/array.rs +++ b/src/vtab/array.rs @@ -180,7 +180,7 @@ mod test { array::load_module(&db).unwrap(); let v = vec![1i64, 2, 3, 4]; - let values = v.into_iter().map(|i| Value::from(i)).collect(); + let values = v.into_iter().map(Value::from).collect(); let ptr = Rc::new(values); { let mut stmt = db.prepare("SELECT value from rarray(?);").unwrap(); diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index b67473a..67659f3 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -366,7 +366,7 @@ mod test { .query_map(NO_PARAMS, |row| row.get::<_, i32>(0)) .unwrap() .collect(); - let sum = ids.unwrap().iter().fold(0, |acc, &id| acc + id); + let sum = ids.unwrap().iter().sum::(); assert_eq!(sum, 15); } db.execute_batch("DROP TABLE vtab").unwrap(); diff --git a/src/vtab/series.rs b/src/vtab/series.rs index 658184a..722ed4b 100644 --- a/src/vtab/series.rs +++ b/src/vtab/series.rs @@ -270,7 +270,7 @@ mod test { #[test] fn test_series_module() { let version = unsafe { ffi::sqlite3_libversion_number() }; - if version < 3008012 { + if version < 3_008_012 { return; } diff --git a/tests/vtab.rs b/tests/vtab.rs index 73d5970..55069b7 100644 --- a/tests/vtab.rs +++ b/tests/vtab.rs @@ -88,7 +88,7 @@ fn test_dummy_module() { .unwrap(); let version = version_number(); - if version < 3008012 { + if version < 3_008_012 { return; }