clippy::single_match_else

This commit is contained in:
gwenn 2022-01-05 19:59:54 +01:00 committed by Thom Chiovoloni
parent 68f41d6e9e
commit c10e2f39ef
5 changed files with 55 additions and 68 deletions

View File

@ -429,19 +429,17 @@ mod build_linked {
}
// See if pkg-config can do everything for us.
match pkg_config::Config::new()
if let Ok(mut lib) = pkg_config::Config::new()
.print_system_libs(false)
.probe(link_lib)
{
Ok(mut lib) => {
if let Some(mut header) = lib.include_paths.pop() {
header.push("sqlite3.h");
HeaderLocation::FromPath(header.to_string_lossy().into())
} else {
HeaderLocation::Wrapper
}
}
Err(_) => {
} else {
// No env var set and pkg-config couldn't help; just output the link-lib
// request and hope that the library exists on the system paths. We used to
// output /usr/lib explicitly, but that can introduce other linking problems;
@ -450,7 +448,6 @@ mod build_linked {
HeaderLocation::Wrapper
}
}
}
fn try_vcpkg() -> Option<HeaderLocation> {
if cfg!(feature = "vcpkg") && is_compiler("msvc") {

View File

@ -84,20 +84,17 @@ unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
ffi::SQLITE_CONSTRAINT
}
match *err {
Error::SqliteFailure(ref err, ref s) => {
if let Error::SqliteFailure(ref err, ref s) = *err {
ffi::sqlite3_result_error_code(ctx, err.extended_code);
if let Some(Ok(cstr)) = s.as_ref().map(|s| str_to_cstring(s)) {
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
}
}
_ => {
} else {
ffi::sqlite3_result_error_code(ctx, constraint_error_code());
if let Ok(cstr) = str_to_cstring(&err.to_string()) {
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
}
}
}
}
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
@ -203,7 +200,7 @@ impl Context<'_> {
arg,
raw as *mut _,
Some(free_boxed_value::<AuxInner>),
)
);
};
Ok(orig)
}
@ -620,12 +617,11 @@ unsafe extern "C" fn call_boxed_step<A, D, T>(
D: Aggregate<A, T>,
T: ToSql,
{
let pac = match aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
Some(pac) => pac,
None => {
let pac = if let Some(pac) = aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
pac
} else {
ffi::sqlite3_result_error_nomem(ctx);
return;
}
};
let r = catch_unwind(|| {
@ -668,12 +664,11 @@ unsafe extern "C" fn call_boxed_inverse<A, W, T>(
W: WindowAggregate<A, T>,
T: ToSql,
{
let pac = match aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
Some(pac) => pac,
None => {
let pac = if let Some(pac) = aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
pac
} else {
ffi::sqlite3_result_error_nomem(ctx);
return;
}
};
let r = catch_unwind(|| {

View File

@ -577,8 +577,7 @@ impl InnerConnection {
}
}
match handler {
Some(handler) => {
if let Some(handler) = handler {
let boxed_handler = Box::new(handler);
unsafe {
ffi::sqlite3_progress_handler(
@ -586,14 +585,12 @@ impl InnerConnection {
num_ops,
Some(call_boxed_closure::<F>),
&*boxed_handler as *const F as *mut _,
)
);
}
self.progress_handler = Some(boxed_handler);
}
_ => {
} else {
unsafe { ffi::sqlite3_progress_handler(self.db(), num_ops, None, ptr::null_mut()) }
self.progress_handler = None;
}
};
}

View File

@ -210,8 +210,8 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
#[inline]
fn advance(&mut self) -> Result<()> {
match self.stmt {
Some(stmt) => match stmt.step() {
if let Some(stmt) = self.stmt {
match stmt.step() {
Ok(true) => {
self.row = Some(Row { stmt });
Ok(())
@ -226,13 +226,12 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
self.row = None;
Err(e)
}
},
None => {
}
} else {
self.row = None;
Ok(())
}
}
}
#[inline]
fn get(&self) -> Option<&Row<'stmt>> {

View File

@ -34,16 +34,15 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> {
drop(catch_unwind(|| callback(err, &s)));
}
let rc = match callback {
Some(f) => ffi::sqlite3_config(
let rc = if let Some(f) = callback {
ffi::sqlite3_config(
ffi::SQLITE_CONFIG_LOG,
log_callback as extern "C" fn(_, _, _),
f as *mut c_void,
),
None => {
)
} else {
let nullptr: *mut c_void = ptr::null_mut();
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
}
};
if rc == ffi::SQLITE_OK {