Reduce required lifetime in create_scalar_function

This commit is contained in:
Nick Hynes 2020-10-25 17:24:34 +03:00 committed by Thom Chiovoloni
parent b0ade73f43
commit 749266cae9

View File

@ -334,15 +334,15 @@ impl Connection {
/// # Failure /// # Failure
/// ///
/// Will return Err if the function could not be attached to the connection. /// Will return Err if the function could not be attached to the connection.
pub fn create_scalar_function<F, T>( pub fn create_scalar_function<'a, F, T>(
&self, &'a self,
fn_name: &str, fn_name: &str,
n_arg: c_int, n_arg: c_int,
flags: FunctionFlags, flags: FunctionFlags,
x_func: F, x_func: F,
) -> Result<()> ) -> Result<()>
where where
F: FnMut(&Context<'_>) -> Result<T> + Send + UnwindSafe + 'static, F: FnMut(&Context<'_>) -> Result<T> + Send + UnwindSafe + 'a,
T: ToSql, T: ToSql,
{ {
self.db self.db
@ -411,15 +411,15 @@ impl Connection {
} }
impl InnerConnection { impl InnerConnection {
fn create_scalar_function<F, T>( fn create_scalar_function<'a, F, T>(
&mut self, &'a mut self,
fn_name: &str, fn_name: &str,
n_arg: c_int, n_arg: c_int,
flags: FunctionFlags, flags: FunctionFlags,
x_func: F, x_func: F,
) -> Result<()> ) -> Result<()>
where where
F: FnMut(&Context<'_>) -> Result<T> + Send + UnwindSafe + 'static, F: FnMut(&Context<'_>) -> Result<T> + Send + UnwindSafe + 'a,
T: ToSql, T: ToSql,
{ {
unsafe extern "C" fn call_boxed_closure<F, T>( unsafe extern "C" fn call_boxed_closure<F, T>(