mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-29 09:02:57 +08:00
Merge pull request #1387 from branchseer/scalar_fn
Change FnMut to Fn in create_scalar_function
This commit is contained in:
commit
e8749fc90b
@ -446,7 +446,7 @@ impl Connection {
|
|||||||
x_func: F,
|
x_func: F,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(&Context<'_>) -> Result<T> + Send + 'static,
|
F: Fn(&Context<'_>) -> Result<T> + Send + 'static,
|
||||||
T: SqlFnOutput,
|
T: SqlFnOutput,
|
||||||
{
|
{
|
||||||
self.db
|
self.db
|
||||||
@ -549,7 +549,7 @@ impl InnerConnection {
|
|||||||
x_func: F,
|
x_func: F,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(&Context<'_>) -> Result<T> + Send + 'static,
|
F: Fn(&Context<'_>) -> Result<T> + Send + 'static,
|
||||||
T: SqlFnOutput,
|
T: SqlFnOutput,
|
||||||
{
|
{
|
||||||
unsafe extern "C" fn call_boxed_closure<F, T>(
|
unsafe extern "C" fn call_boxed_closure<F, T>(
|
||||||
@ -557,12 +557,12 @@ impl InnerConnection {
|
|||||||
argc: c_int,
|
argc: c_int,
|
||||||
argv: *mut *mut sqlite3_value,
|
argv: *mut *mut sqlite3_value,
|
||||||
) where
|
) where
|
||||||
F: FnMut(&Context<'_>) -> Result<T>,
|
F: Fn(&Context<'_>) -> Result<T>,
|
||||||
T: SqlFnOutput,
|
T: SqlFnOutput,
|
||||||
{
|
{
|
||||||
let args = slice::from_raw_parts(argv, argc as usize);
|
let args = slice::from_raw_parts(argv, argc as usize);
|
||||||
let r = catch_unwind(|| {
|
let r = catch_unwind(|| {
|
||||||
let boxed_f: *mut F = ffi::sqlite3_user_data(ctx).cast::<F>();
|
let boxed_f: *const F = ffi::sqlite3_user_data(ctx).cast::<F>();
|
||||||
assert!(!boxed_f.is_null(), "Internal error - null function pointer");
|
assert!(!boxed_f.is_null(), "Internal error - null function pointer");
|
||||||
let ctx = Context { ctx, args };
|
let ctx = Context { ctx, args };
|
||||||
(*boxed_f)(&ctx)
|
(*boxed_f)(&ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user