From 2319165b5963e56aaed8d05361a40c05edf85480 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Jan 2021 10:49:29 +0100 Subject: [PATCH 1/2] Fix clippy warnings --- src/pragma.rs | 8 ++++---- src/statement.rs | 2 ++ src/vtab/array.rs | 2 +- src/vtab/mod.rs | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pragma.rs b/src/pragma.rs index 259d970..d218951 100644 --- a/src/pragma.rs +++ b/src/pragma.rs @@ -298,15 +298,15 @@ fn is_identifier(s: &str) -> bool { } fn is_identifier_start(c: char) -> bool { - (c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z') || c > '\x7F' + ('A'..='Z').contains(&c) || c == '_' || ('a'..='z').contains(&c) || c > '\x7F' } fn is_identifier_continue(c: char) -> bool { c == '$' - || (c >= '0' && c <= '9') - || (c >= 'A' && c <= 'Z') + || ('0'..='9').contains(&c) + || ('A'..='Z').contains(&c) || c == '_' - || (c >= 'a' && c <= 'z') + || ('a'..='z').contains(&c) || c > '\x7F' } diff --git a/src/statement.rs b/src/statement.rs index b749e26..5993d03 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -718,12 +718,14 @@ impl Statement<'_> { self.conn.decode_result(stmt.finalize()) } + #[allow(clippy::unnecessary_wraps)] #[cfg(not(feature = "modern_sqlite"))] #[inline] fn check_readonly(&self) -> Result<()> { Ok(()) } + #[allow(clippy::unnecessary_wraps)] #[cfg(feature = "modern_sqlite")] #[inline] fn check_readonly(&self) -> Result<()> { diff --git a/src/vtab/array.rs b/src/vtab/array.rs index 53b31a7..bd3197a 100644 --- a/src/vtab/array.rs +++ b/src/vtab/array.rs @@ -157,7 +157,7 @@ impl ArrayTabCursor<'_> { unsafe impl VTabCursor for ArrayTabCursor<'_> { fn filter(&mut self, idx_num: c_int, _idx_str: Option<&str>, args: &Values<'_>) -> Result<()> { if idx_num > 0 { - self.ptr = args.get_array(0)?; + self.ptr = args.get_array(0); } else { self.ptr = None; } diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index ee095f0..4d9ad65 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -571,19 +571,19 @@ impl Values<'_> { // `sqlite3_value_type` returns `SQLITE_NULL` for pointer. // So it seems not possible to enhance `ValueRef::from_value`. #[cfg(feature = "array")] - fn get_array(&self, idx: usize) -> Result> { + fn get_array(&self, idx: usize) -> Option { use crate::types::Value; let arg = self.args[idx]; let ptr = unsafe { ffi::sqlite3_value_pointer(arg, array::ARRAY_TYPE) }; if ptr.is_null() { - Ok(None) + None } else { - Ok(Some(unsafe { + Some(unsafe { let rc = array::Array::from_raw(ptr as *const Vec); let array = rc.clone(); array::Array::into_raw(rc); // don't consume it array - })) + }) } } From 70742651b10069cd9b9ac171fc3871f04ee35bc9 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Jan 2021 13:43:12 +0100 Subject: [PATCH 2/2] Fix CI build clippy::unnecessary_wraps is not stable yet --- src/statement.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/statement.rs b/src/statement.rs index 5993d03..b749e26 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -718,14 +718,12 @@ impl Statement<'_> { self.conn.decode_result(stmt.finalize()) } - #[allow(clippy::unnecessary_wraps)] #[cfg(not(feature = "modern_sqlite"))] #[inline] fn check_readonly(&self) -> Result<()> { Ok(()) } - #[allow(clippy::unnecessary_wraps)] #[cfg(feature = "modern_sqlite")] #[inline] fn check_readonly(&self) -> Result<()> {