pub fn new<T>(
        mut store: impl AsContextMut<Data = T>,
        ty: FuncType,
        func: impl Fn(Caller<'_, T>, &[Val], &mut [Val]) -> Result<(), Trap> + Send + Sync + 'static,
    ) -> Self {
        let mut store = store.as_context_mut().opaque();

        // part of this unsafety is about matching the `T` to a `Store<T>`,
        // which is done through the `AsContextMut` bound above.
        unsafe {
            let host = HostFunc::new(store.engine(), ty, func);
            host.into_func(&mut store)
        }
    }
/// Creates a new `Func` with the given arguments, typically to create a
/// host-defined function to pass as an import to a module.
///
/// * `store` - the store in which to create this [`Func`], which will own
///   the return value.
///
/// * `ty` - the signature of this function, used to indicate what the
///   inputs and outputs are.
///
/// * `func` - the native code invoked whenever this `Func` will be called.
///   This closure is provided a [`Caller`] as its first argument to learn
///   information about the caller, and then it's passed a list of
///   parameters as a slice along with a mutable slice of where to write
///   results.
///
/// Note that the implementation of `func` must adhere to the `ty` signature
/// given, error or traps may occur if it does not respect the `ty`
/// signature. For example if the function type declares that it returns one
/// i32 but the `func` closures does not write anything into the results
/// slice then a trap may be generated.
///
/// Additionally note that this is quite a dynamic function since signatures
/// are not statically known. For a more performant and ergonomic `Func`
/// it's recommended to use [`Func::wrap`] if you can because with
/// statically known signatures Wasmtime can optimize the implementation
/// much more.
///
/// For more information about `Send + Sync + 'static` requirements on the
/// `func`, see [`Func::wrap`](#why-send--sync--static).
Creates a new `Func` with the given arguments, typically to create a
host-defined function to pass as an import to a module.

`store` - the store in which to create this [`Func`], which will own
the return value.

`ty` - the signature of this function, used to indicate what the
inputs and outputs are.

`func` - the native code invoked whenever this `Func` will be called.
This closure is provided a [`Caller`] as its first argument to learn
information about the caller, and then it's passed a list of
parameters as a slice along with a mutable slice of where to write
results.



Additionally note that this is quite a dynamic function since signatures
are not statically known. For a more performant and ergonomic `Func`
it's recommended to use [`Func::wrap`] if you can because with
statically known signatures Wasmtime can optimize the implementation
much more.


Creates a new ` Func ` with the given arguments typically to create a host - defined function to pass as an import to a module . ` store ` - the store in which to create this [ ` Func ` ] which will own the return value . ` ty ` - the signature of this function used to indicate what the inputs and outputs are . ` func ` - the native code invoked whenever this ` Func ` will be called . This closure is provided a [ ` Caller ` ] as its first argument to learn information about the caller and then it ' s passed a list of parameters as a slice along with a mutable slice of where to write results . Additionally note that this is quite a dynamic function since signatures are not statically known . For a more performant and ergonomic ` Func ` it ' s recommended to use [ ` Func :: wrap ` ] if you can because with statically known signatures Wasmtime can optimize the implementation much more .
pub fn new<T>(
        mut store: impl AsContextMut<Data = T>,
        ty: FuncType,
        func: impl Fn(Caller<'_, T>, &[Val], &mut [Val]) -> Result<(), Trap> + Send + Sync + 'static,
    ) -> Self {
        let mut store = store.as_context_mut().opaque();
        // part of this unsafety is about matching the `T` to a `Store<T>`,
        // which is done through the `AsContextMut` bound above.
        unsafe {
            let host = HostFunc::new(store.engine(), ty, func);
            host.into_func(&mut store)
        }
    }
pub fn new < T > ( mut store : impl AsContextMut < Data = T > , ty : FuncType , func : impl Fn ( Caller < ' _ , T > , & [ Val ] , & mut [ Val ] ) -> Result < ( ) , Trap > + Send + Sync + ' static , ) -> Self { let mut store = store . as_context_mut ( ) . opaque ( ) ; // part of this unsafety is about matching the `T` to a `Store<T>`, // which is done through the `AsContextMut` bound above. unsafe { let host = HostFunc :: new ( store . engine ( ) , ty , func ) ; host . into_func ( & mut store ) } }
Creates a new `Func` with the given arguments, typically to create a
host-defined function to pass as an import to a module.
Creates a new ` Func ` with the given arguments typically to create a host - defined function to pass as an import to a module .
store
impl AsContextMut<Data = T>
ty
FuncType
func
impl Fn(Caller<'_, T>, &[Val], &mut [Val]) -> Result<(), Trap> + Send + Sync + 'static
store
impl AsContextMut<Data = T>
ty
FuncType
func
impl Fn(Caller<'_, T>, &[Val], &mut [Val]) -> Result<(), Trap> + Send + Sync + 'static