structs that contain pointers work!

This commit is contained in:
Pat Hickey
2020-01-28 18:17:48 -08:00
parent 35d9373976
commit 814dd19488
5 changed files with 162 additions and 1 deletions

View File

@@ -67,6 +67,15 @@ pub mod test {
println!("sum of pair: {:?}", an_pair);
Ok(an_pair.first as i64 + an_pair.second as i64)
}
fn sum_of_pair_of_ptrs(
&mut self,
an_pair: &types::PairIntPtrs,
) -> Result<i64, types::Errno> {
let first = *an_pair.first.as_ref().unwrap();
let second = *an_pair.second.as_ref().unwrap();
println!("sum of pair of ptrs: {} + {}", first, second);
Ok(first as i64 + second as i64)
}
}
// Errno is used as a first return value in the functions above, therefore
// it must implement GuestErrorType with type Context = WasiCtx.