mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-04 14:52: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();
|
let mut imports = Imports::new();
|
||||||
imports.add(
|
imports.add(
|
||||||
"env".to_string(),
|
"env",
|
||||||
"print_num".to_string(),
|
"print_num",
|
||||||
Import::Func(
|
Import::Func(
|
||||||
unsafe { FuncRef::new(print_num as _) },
|
unsafe { FuncRef::new(print_num as _) },
|
||||||
FuncSig {
|
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
|
self.map
|
||||||
.entry(module)
|
.entry(module.into())
|
||||||
.or_insert(HashMap::new())
|
.or_insert_with(|| HashMap::new())
|
||||||
.insert(name, import);
|
.insert(name.into(), import);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, module: &str, name: &str) -> Option<&Import> {
|
pub fn get(&self, module: &str, name: &str) -> Option<&Import> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user