Put context object behind a ref rather than mut ref

This commit puts context object, i.e., the implementor of the
WASI snapshot, behind a reference `&self` rather than a mutable
reference `&mut self`. As suggested by @alexcrichton, this gives
the implementor the possibility to determine how it handles its
interior mutability.
This commit is contained in:
Jakub Konka
2020-03-03 15:25:11 +01:00
committed by Jakub Konka
parent ea4d2d0535
commit 3764204250
13 changed files with 74 additions and 78 deletions

View File

@@ -10,7 +10,7 @@ wiggle::from_witx!({
impl_errno!(types::Errno);
impl strings::Strings for WasiCtx {
fn hello_string(&mut self, a_string: &GuestString<'_>) -> Result<u32, types::Errno> {
fn hello_string(&self, a_string: &GuestString<'_>) -> Result<u32, types::Errno> {
let as_ref = a_string.as_ref().expect("deref ptr should succeed");
let as_str = as_ref.as_str().expect("valid UTF-8 string");
println!("a_string='{}'", as_str);