Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Aug 20, 2019
1 parent a3b6164 commit 05624b0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 412 deletions.
11 changes: 7 additions & 4 deletions wasmtime-api/examples/gcd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use failure::Error;
use failure::{format_err, Error};
use std::cell::RefCell;
use std::fs::read;
use std::rc::Rc;
use wasm_rust_api::*;
use wasmtime_api::*;

fn main() -> Result<(), Error> {
let wasm = read("gcd.wasm")?;
let wasm = read("examples/gcd.wasm")?;
let engine = Rc::new(RefCell::new(Engine::default()));
let store = Rc::new(RefCell::new(Store::new(engine)));
let module = Rc::new(RefCell::new(Module::new(store.clone(), &wasm)?));
Expand All @@ -22,7 +22,10 @@ fn main() -> Result<(), Error> {
.borrow()
.func()
.clone();
let result = gcd.borrow().call(&[Val::from(6i32), Val::from(27i32)])?;
let result = gcd
.borrow()
.call(&[Val::from(6i32), Val::from(27i32)])
.map_err(|e| format_err!("call error: {:?}", e))?;
println!("{:?}", result);
Ok(())
}
Binary file added wasmtime-api/examples/gcd.wasm
Binary file not shown.
Loading

0 comments on commit 05624b0

Please sign in to comment.