mirror of
https://github.com/isar/rusqlite.git
synced 2025-02-08 07:30:51 +08:00
clippy::single_match_else
This commit is contained in:
parent
68f41d6e9e
commit
c10e2f39ef
@ -429,26 +429,23 @@ mod build_linked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// See if pkg-config can do everything for us.
|
// 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)
|
.print_system_libs(false)
|
||||||
.probe(link_lib)
|
.probe(link_lib)
|
||||||
{
|
{
|
||||||
Ok(mut lib) => {
|
if let Some(mut header) = lib.include_paths.pop() {
|
||||||
if let Some(mut header) = lib.include_paths.pop() {
|
header.push("sqlite3.h");
|
||||||
header.push("sqlite3.h");
|
HeaderLocation::FromPath(header.to_string_lossy().into())
|
||||||
HeaderLocation::FromPath(header.to_string_lossy().into())
|
} else {
|
||||||
} else {
|
|
||||||
HeaderLocation::Wrapper
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
// 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;
|
|
||||||
// see https://github.com/rusqlite/rusqlite/issues/207.
|
|
||||||
println!("cargo:rustc-link-lib={}={}", find_link_mode(), link_lib);
|
|
||||||
HeaderLocation::Wrapper
|
HeaderLocation::Wrapper
|
||||||
}
|
}
|
||||||
|
} 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;
|
||||||
|
// see https://github.com/rusqlite/rusqlite/issues/207.
|
||||||
|
println!("cargo:rustc-link-lib={}={}", find_link_mode(), link_lib);
|
||||||
|
HeaderLocation::Wrapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,18 +84,15 @@ unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
|||||||
ffi::SQLITE_CONSTRAINT
|
ffi::SQLITE_CONSTRAINT
|
||||||
}
|
}
|
||||||
|
|
||||||
match *err {
|
if let Error::SqliteFailure(ref err, ref s) = *err {
|
||||||
Error::SqliteFailure(ref err, ref s) => {
|
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
||||||
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
if let Some(Ok(cstr)) = s.as_ref().map(|s| str_to_cstring(s)) {
|
||||||
if let Some(Ok(cstr)) = s.as_ref().map(|s| str_to_cstring(s)) {
|
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
||||||
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {
|
} else {
|
||||||
ffi::sqlite3_result_error_code(ctx, constraint_error_code());
|
ffi::sqlite3_result_error_code(ctx, constraint_error_code());
|
||||||
if let Ok(cstr) = str_to_cstring(&err.to_string()) {
|
if let Ok(cstr) = str_to_cstring(&err.to_string()) {
|
||||||
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,7 +200,7 @@ impl Context<'_> {
|
|||||||
arg,
|
arg,
|
||||||
raw as *mut _,
|
raw as *mut _,
|
||||||
Some(free_boxed_value::<AuxInner>),
|
Some(free_boxed_value::<AuxInner>),
|
||||||
)
|
);
|
||||||
};
|
};
|
||||||
Ok(orig)
|
Ok(orig)
|
||||||
}
|
}
|
||||||
@ -620,12 +617,11 @@ unsafe extern "C" fn call_boxed_step<A, D, T>(
|
|||||||
D: Aggregate<A, T>,
|
D: Aggregate<A, T>,
|
||||||
T: ToSql,
|
T: ToSql,
|
||||||
{
|
{
|
||||||
let pac = match aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
|
let pac = if let Some(pac) = aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
|
||||||
Some(pac) => pac,
|
pac
|
||||||
None => {
|
} else {
|
||||||
ffi::sqlite3_result_error_nomem(ctx);
|
ffi::sqlite3_result_error_nomem(ctx);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let r = catch_unwind(|| {
|
let r = catch_unwind(|| {
|
||||||
@ -668,12 +664,11 @@ unsafe extern "C" fn call_boxed_inverse<A, W, T>(
|
|||||||
W: WindowAggregate<A, T>,
|
W: WindowAggregate<A, T>,
|
||||||
T: ToSql,
|
T: ToSql,
|
||||||
{
|
{
|
||||||
let pac = match aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
|
let pac = if let Some(pac) = aggregate_context(ctx, ::std::mem::size_of::<*mut A>()) {
|
||||||
Some(pac) => pac,
|
pac
|
||||||
None => {
|
} else {
|
||||||
ffi::sqlite3_result_error_nomem(ctx);
|
ffi::sqlite3_result_error_nomem(ctx);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let r = catch_unwind(|| {
|
let r = catch_unwind(|| {
|
||||||
|
29
src/hooks.rs
29
src/hooks.rs
@ -577,23 +577,20 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match handler {
|
if let Some(handler) = handler {
|
||||||
Some(handler) => {
|
let boxed_handler = Box::new(handler);
|
||||||
let boxed_handler = Box::new(handler);
|
unsafe {
|
||||||
unsafe {
|
ffi::sqlite3_progress_handler(
|
||||||
ffi::sqlite3_progress_handler(
|
self.db(),
|
||||||
self.db(),
|
num_ops,
|
||||||
num_ops,
|
Some(call_boxed_closure::<F>),
|
||||||
Some(call_boxed_closure::<F>),
|
&*boxed_handler as *const F as *mut _,
|
||||||
&*boxed_handler as *const F as *mut _,
|
);
|
||||||
)
|
|
||||||
}
|
|
||||||
self.progress_handler = Some(boxed_handler);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
unsafe { ffi::sqlite3_progress_handler(self.db(), num_ops, None, ptr::null_mut()) }
|
|
||||||
self.progress_handler = None;
|
|
||||||
}
|
}
|
||||||
|
self.progress_handler = Some(boxed_handler);
|
||||||
|
} else {
|
||||||
|
unsafe { ffi::sqlite3_progress_handler(self.db(), num_ops, None, ptr::null_mut()) }
|
||||||
|
self.progress_handler = None;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/row.rs
11
src/row.rs
@ -210,8 +210,8 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn advance(&mut self) -> Result<()> {
|
fn advance(&mut self) -> Result<()> {
|
||||||
match self.stmt {
|
if let Some(stmt) = self.stmt {
|
||||||
Some(stmt) => match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
self.row = Some(Row { stmt });
|
self.row = Some(Row { stmt });
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -226,11 +226,10 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
|
|||||||
self.row = None;
|
self.row = None;
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
None => {
|
|
||||||
self.row = None;
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
self.row = None;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/trace.rs
13
src/trace.rs
@ -34,16 +34,15 @@ pub unsafe fn config_log(callback: Option<fn(c_int, &str)>) -> Result<()> {
|
|||||||
drop(catch_unwind(|| callback(err, &s)));
|
drop(catch_unwind(|| callback(err, &s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let rc = match callback {
|
let rc = if let Some(f) = callback {
|
||||||
Some(f) => ffi::sqlite3_config(
|
ffi::sqlite3_config(
|
||||||
ffi::SQLITE_CONFIG_LOG,
|
ffi::SQLITE_CONFIG_LOG,
|
||||||
log_callback as extern "C" fn(_, _, _),
|
log_callback as extern "C" fn(_, _, _),
|
||||||
f as *mut c_void,
|
f as *mut c_void,
|
||||||
),
|
)
|
||||||
None => {
|
} else {
|
||||||
let nullptr: *mut c_void = ptr::null_mut();
|
let nullptr: *mut c_void = ptr::null_mut();
|
||||||
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
|
ffi::sqlite3_config(ffi::SQLITE_CONFIG_LOG, nullptr, nullptr)
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if rc == ffi::SQLITE_OK {
|
if rc == ffi::SQLITE_OK {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user