Only require str in new_with_name (#796)

* Only require `str` in `new_with_name`

It's a bit more idiomatic to have APIs require `&str` rather than
`String`, and the allocation doesn't matter much here since creating a
`Module` is pretty expensive anyway.

* Update a test
This commit is contained in:
Alex Crichton
2020-01-10 13:17:41 -06:00
committed by GitHub
parent 6571fb8f4f
commit 6b3ee47915
4 changed files with 14 additions and 20 deletions

View File

@@ -27,7 +27,7 @@ impl Resolver for SimpleResolver<'_> {
pub fn instantiate_in_context(
data: &[u8],
imports: &[Extern],
module_name: Option<String>,
module_name: Option<&str>,
context: Context,
exports: Rc<RefCell<HashMap<String, Option<wasmtime_runtime::Export>>>>,
) -> Result<(InstanceHandle, HashSet<Context>), Error> {
@@ -74,7 +74,7 @@ impl Instance {
let (mut instance_handle, contexts) = instantiate_in_context(
module.binary().expect("binary"),
externs,
module.name().cloned(),
module.name(),
context,
exports,
)?;