pub fn new(module: &Module, imports: &[Extern]) -> Result<Instance, Error> {
        let store = module.store();
        let mut instance_handle =
            instantiate(module.compiled_module().expect("compiled_module"), imports)?;

        let exports = {
            let mut exports = Vec::with_capacity(module.exports().len());
            for export in module.exports() {
                let name = export.name().to_string();
                let export = instance_handle.lookup(&name).expect("export");
                exports.push(Extern::from_wasmtime_export(
                    store,
                    instance_handle.clone(),
                    export,
                ));
            }
            exports.into_boxed_slice()
        };
        Ok(Instance {
            instance_handle,
            module: module.clone(),
            exports,
        })
    }
/// Creates a new [`Instance`] from the previously compiled [`Module`] and
/// list of `imports` specified.
///
/// This method instantiates the `module` provided with the `imports`,
/// following the procedure in the [core specification][inst] to
/// instantiate. Instantiation can fail for a number of reasons (many
/// specified below), but if successful the `start` function will be
/// automatically run (if provided) and then the [`Instance`] will be
/// returned.
///
/// ## Providing Imports
///
/// The `imports` array here is a bit tricky. The entries in the list of
/// `imports` are intended to correspond 1:1 with the list of imports
/// returned by [`Module::imports`]. Before calling [`Instance::new`] you'll
/// want to inspect the return value of [`Module::imports`] and, for each
/// import type, create an [`Extern`] which corresponds to that type.
/// These [`Extern`] values are all then collected into a list and passed to
/// this function.
///
/// Note that this function is intentionally relatively low level. It is the
/// intention that we'll soon provide a [higher level API][issue] which will
/// be much more ergonomic for instantiating modules. If you need the full
/// power of customization of imports, though, this is the method for you!
///
/// ## Errors
///
/// This function can fail for a number of reasons, including, but not
/// limited to:
///
/// * The number of `imports` provided doesn't match the number of imports
///   returned by the `module`'s [`Module::imports`] method.
/// * The type of any [`Extern`] doesn't match the corresponding
///   [`ExternType`] entry that it maps to.
/// * The `start` function in the instance, if present, traps.
/// * Module/instance resource limits are exceeded.
///
/// When instantiation fails it's recommended to inspect the return value to
/// see why it failed, or bubble it upwards. If you'd like to specifically
/// check for trap errors, you can use `error.downcast::<Trap>()`.
///
/// [inst]: https://webassembly.github.io/spec/core/exec/modules.html#exec-instantiation
/// [issue]: https://github.com/bytecodealliance/wasmtime/issues/727


This method instantiates the `module` provided with the `imports`,
following the procedure in the [core specification][inst] to
instantiate. Instantiation can fail for a number of reasons (many
specified below), but if successful the `start` function will be
automatically run (if provided) and then the [`Instance`] will be
returned.
This method instantiates the ` module ` provided with the ` imports ` following the procedure in the [ core specification ] [ inst ] to instantiate . Instantiation can fail for a number of reasons ( many specified below ) but if successful the ` start ` function will be automatically run ( if provided ) and then the [ ` Instance ` ] will be returned .
pub fn new(module: &Module, imports: &[Extern]) -> Result<Instance, Error> {
        let store = module.store();
        let mut instance_handle =
            instantiate(module.compiled_module().expect("compiled_module"), imports)?;
        let exports = {
            let mut exports = Vec::with_capacity(module.exports().len());
            for export in module.exports() {
                let name = export.name().to_string();
                let export = instance_handle.lookup(&name).expect("export");
                exports.push(Extern::from_wasmtime_export(
                    store,
                    instance_handle.clone(),
                    export,
                ));
            }
            exports.into_boxed_slice()
        };
        Ok(Instance {
            instance_handle,
            module: module.clone(),
            exports,
        })
    }
pub fn new ( module : & Module , imports : & [ Extern ] ) -> Result < Instance , Error > { let store = module . store ( ) ; let mut instance_handle = instantiate ( module . compiled_module ( ) . expect ( " " ) , imports ) ? ; let exports = { let mut exports = Vec :: with_capacity ( module . exports ( ) . len ( ) ) ; for export in module . exports ( ) { let name = export . name ( ) . to_string ( ) ; let export = instance_handle . lookup ( & name ) . expect ( " " ) ; exports . push ( Extern :: from_wasmtime_export ( store , instance_handle . clone ( ) , export , ) ) ; } exports . into_boxed_slice ( ) } ; Ok ( Instance { instance_handle , module : module . clone ( ) , exports , } ) }
Creates a new [`Instance`] from the previously compiled [`Module`] and
list of `imports` specified.
Creates a new [ ` Instance ` ] from the previously compiled [ ` Module ` ] and list of ` imports ` specified .
module
&Module
imports
&[Extern]
module
&Module
imports
&[Extern]
providing imports
The `imports` array here is a bit tricky. The entries in the list of
`imports` are intended to correspond 1:1 with the list of imports
returned by [`Module::imports`]. Before calling [`Instance::new`] you'll
want to inspect the return value of [`Module::imports`] and, for each
import type, create an [`Extern`] which corresponds to that type.
These [`Extern`] values are all then collected into a list and passed to
this function.

Note that this function is intentionally relatively low level. It is the
intention that we'll soon provide a [higher level API][issue] which will
be much more ergonomic for instantiating modules. If you need the full
power of customization of imports, though, this is the method for you!
The ` imports ` array here is a bit tricky . The entries in the list of ` imports ` are intended to correspond 1 : 1 with the list of imports returned by [ ` Module :: imports ` ] . Before calling [ ` Instance :: new ` ] you ' ll want to inspect the return value of [ ` Module :: imports ` ] and for each import type create an [ ` Extern ` ] which corresponds to that type . These [ ` Extern ` ] values are all then collected into a list and passed to this function . Note that this function is intentionally relatively low level . It is the intention that we ' ll soon provide a [ higher level API ] [ issue ] which will be much more ergonomic for instantiating modules . If you need the full power of customization of imports though this is the method for you!
errors
This function can fail for a number of reasons, including, but not
limited to.

The number of `imports` provided doesn't match the number of imports
returned by the `module`'s [`Module::imports`] method.
The type of any [`Extern`] doesn't match the corresponding
[`ExternType`] entry that it maps to.
The `start` function in the instance, if present, traps.
Module/instance resource limits are exceeded.

When instantiation fails it's recommended to inspect the return value to
see why it failed, or bubble it upwards. If you'd like to specifically
check for trap errors, you can use `error.downcast::()`.


This function can fail for a number of reasons including but not limited to . The number of ` imports ` provided doesn ' t match the number of imports returned by the ` module ` ' s [ ` Module :: imports ` ] method . The type of any [ ` Extern ` ] doesn ' t match the corresponding [ ` ExternType ` ] entry that it maps to . The ` start ` function in the instance if present traps . Module / instance resource limits are exceeded . When instantiation fails it ' s recommended to inspect the return value to see why it failed or bubble it upwards . If you ' d like to specifically check for trap errors you can use ` error . downcast :: () ` .