mirror of
https://github.com/isar/rusqlite.git
synced 2025-02-08 07:10:50 +08:00
clippy::single_match_else
This commit is contained in:
parent
68f41d6e9e
commit
c10e2f39ef
@ -429,19 +429,17 @@ 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
|
HeaderLocation::Wrapper
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
Err(_) => {
|
|
||||||
// No env var set and pkg-config couldn't help; just output the link-lib
|
// 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
|
// 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;
|
// output /usr/lib explicitly, but that can introduce other linking problems;
|
||||||
@ -450,7 +448,6 @@ mod build_linked {
|
|||||||
HeaderLocation::Wrapper
|
HeaderLocation::Wrapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn try_vcpkg() -> Option<HeaderLocation> {
|
fn try_vcpkg() -> Option<HeaderLocation> {
|
||||||
if cfg!(feature = "vcpkg") && is_compiler("msvc") {
|
if cfg!(feature = "vcpkg") && is_compiler("msvc") {
|
||||||
|
@ -84,21 +84,18 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
||||||
drop(Box::from_raw(p as *mut T));
|
drop(Box::from_raw(p as *mut T));
|
||||||
@ -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(|| {
|
||||||
|
@ -577,8 +577,7 @@ 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(
|
||||||
@ -586,14 +585,12 @@ impl InnerConnection {
|
|||||||
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);
|
self.progress_handler = Some(boxed_handler);
|
||||||
}
|
} else {
|
||||||
_ => {
|
|
||||||
unsafe { ffi::sqlite3_progress_handler(self.db(), num_ops, None, ptr::null_mut()) }
|
unsafe { ffi::sqlite3_progress_handler(self.db(), num_ops, None, ptr::null_mut()) }
|
||||||
self.progress_handler = None;
|
self.progress_handler = None;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,13 +226,12 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
|
|||||||
self.row = None;
|
self.row = None;
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => {
|
} else {
|
||||||
self.row = None;
|
self.row = None;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get(&self) -> Option<&Row<'stmt>> {
|
fn get(&self) -> Option<&Row<'stmt>> {
|
||||||
|
@ -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