MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / main

Function main

examples/fib-debug/main.rs:13–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11use wasmtime::*;
12
13fn main() -> Result<()> {
14 // Load our previously compiled wasm file (built previously with Cargo) and
15 // also ensure that we generate debuginfo so this executable can be
16 // debugged in GDB.
17 let engine = Engine::new(
18 Config::new()
19 .debug_info(true)
20 .cranelift_opt_level(OptLevel::None),
21 )?;
22 let mut store = Store::new(&engine, ());
23 let module = Module::from_file(&engine, "target/wasm32-unknown-unknown/debug/fib.wasm")?;
24 let instance = Instance::new(&mut store, &module, &[])?;
25
26 // Invoke `fib` export
27 let fib = instance.get_typed_func::<i32, i32>(&mut store, "fib")?;
28 println!("fib(6) = {}", fib.call(&mut store, 6)?);
29 Ok(())
30}

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
newFunction · 0.50
cranelift_opt_levelMethod · 0.45
debug_infoMethod · 0.45

Tested by

no test coverage detected