Merge pull request #795 from gwenn/clippy

Fix clippy warnings
This commit is contained in:
gwenn 2020-08-17 20:18:29 +02:00 committed by GitHub
commit 301a8d0e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 16 deletions

View File

@ -60,7 +60,7 @@ impl Connection {
let mut c = self.db.borrow_mut();
let r = match callback {
Some(f) => unsafe {
ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), mem::transmute(f))
ffi::sqlite3_busy_handler(c.db(), Some(busy_handler_callback), f as *mut c_void)
},
None => unsafe { ffi::sqlite3_busy_handler(c.db(), None, ptr::null_mut()) },
};

View File

@ -132,7 +132,7 @@ impl InnerConnection {
let r = unsafe {
ffi::sqlite3_collation_needed(
self.db(),
mem::transmute(x_coll_needed),
x_coll_needed as *mut c_void,
Some(collation_needed_callback),
)
};

View File

@ -35,14 +35,11 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> {
}
let rc = match callback {
Some(f) => {
let p_arg: *mut c_void = mem::transmute(f);
ffi::sqlite3_config(
Some(f) => ffi::sqlite3_config(
ffi::SQLITE_CONFIG_LOG,
log_callback as extern "C" fn(_, _, _),
p_arg,
)
}
f as *mut c_void,
),
None => {
let nullptr: *mut c_void = ptr::null_mut();
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
@ -83,7 +80,7 @@ impl Connection {
let c = self.db.borrow_mut();
match trace_fn {
Some(f) => unsafe {
ffi::sqlite3_trace(c.db(), Some(trace_callback), mem::transmute(f));
ffi::sqlite3_trace(c.db(), Some(trace_callback), f as *mut c_void);
},
None => unsafe {
ffi::sqlite3_trace(c.db(), None, ptr::null_mut());
@ -117,7 +114,7 @@ impl Connection {
let c = self.db.borrow_mut();
match profile_fn {
Some(f) => unsafe {
ffi::sqlite3_profile(c.db(), Some(profile_callback), mem::transmute(f))
ffi::sqlite3_profile(c.db(), Some(profile_callback), f as *mut c_void)
},
None => unsafe { ffi::sqlite3_profile(c.db(), None, ptr::null_mut()) },
};

View File

@ -143,10 +143,7 @@ impl FromSql for f64 {
impl FromSql for bool {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
i64::column_result(value).map(|i| match i {
0 => false,
_ => true,
})
i64::column_result(value).map(|i| !matches!(i, 0))
}
}