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