mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-03 14:22:14 +00:00
Improve imports ergonomics
This commit is contained in:
parent
82771673b5
commit
cfaa9ff494
@ -12,8 +12,8 @@ fn main() -> Result<(), String> {
|
||||
|
||||
let mut imports = Imports::new();
|
||||
imports.add(
|
||||
"env".to_string(),
|
||||
"print_num".to_string(),
|
||||
"env",
|
||||
"print_num",
|
||||
Import::Func(
|
||||
unsafe { FuncRef::new(print_num as _) },
|
||||
FuncSig {
|
||||
|
@ -169,11 +169,11 @@ impl Imports {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add(&mut self, module: String, name: String, import: Import) {
|
||||
pub fn add(&mut self, module: impl Into<String>, name: impl Into<String>, import: Import) {
|
||||
self.map
|
||||
.entry(module)
|
||||
.or_insert(HashMap::new())
|
||||
.insert(name, import);
|
||||
.entry(module.into())
|
||||
.or_insert_with(|| HashMap::new())
|
||||
.insert(name.into(), import);
|
||||
}
|
||||
|
||||
pub fn get(&self, module: &str, name: &str) -> Option<&Import> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user