From 5f6ac80e7a3c7511519d9131eeee2a10a7a2c091 Mon Sep 17 00:00:00 2001
From: patr0nus <dk4rest@gmail.com>
Date: Fri, 8 Sep 2023 00:30:00 +0800
Subject: [PATCH] FnMut ->  Fn in create_scalar_function

Change FnMut to Fn in InnerConnection::create_scalar_function

cast user data as shared reference
---
 src/functions.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/functions.rs b/src/functions.rs
index 4aef3f3..4e0469d 100644
--- a/src/functions.rs
+++ b/src/functions.rs
@@ -446,7 +446,7 @@ impl Connection {
         x_func: F,
     ) -> Result<()>
     where
-        F: FnMut(&Context<'_>) -> Result<T> + Send + 'static,
+        F: Fn(&Context<'_>) -> Result<T> + Send + 'static,
         T: SqlFnOutput,
     {
         self.db
@@ -549,7 +549,7 @@ impl InnerConnection {
         x_func: F,
     ) -> Result<()>
     where
-        F: FnMut(&Context<'_>) -> Result<T> + Send + 'static,
+        F: Fn(&Context<'_>) -> Result<T> + Send + 'static,
         T: SqlFnOutput,
     {
         unsafe extern "C" fn call_boxed_closure<F, T>(
@@ -557,12 +557,12 @@ impl InnerConnection {
             argc: c_int,
             argv: *mut *mut sqlite3_value,
         ) where
-            F: FnMut(&Context<'_>) -> Result<T>,
+            F: Fn(&Context<'_>) -> Result<T>,
             T: SqlFnOutput,
         {
             let args = slice::from_raw_parts(argv, argc as usize);
             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");
                 let ctx = Context { ctx, args };
                 (*boxed_f)(&ctx)