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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user