wasmer/lib/wasi/src/macros.rs
2019-04-01 16:34:18 -07:00

14 lines
336 B
Rust

macro_rules! wasi_try {
($expr:expr) => {{
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
match res {
Ok(val) => val,
Err(err) => return err,
}
}};
($expr:expr; $e:expr) => {{
let opt: Option<_> = $expr;
wasi_try!(opt.ok_or($e))
}};
}