From 3ac431eb3ca51abe618f1aff44be12a5026fda76 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Fri, 21 Apr 2023 11:38:33 +0200 Subject: [PATCH] Fixed FunctionEnv migration doc to 3.0 (#3806) --- docs/migration_to_3.0.0.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/migration_to_3.0.0.md b/docs/migration_to_3.0.0.md index f4aab909224..91582cf002b 100644 --- a/docs/migration_to_3.0.0.md +++ b/docs/migration_to_3.0.0.md @@ -112,10 +112,11 @@ let env = FunctionEnv::new(&mut store, MyEnv { multiply_by: 10, }); -let instance = Instance::new(&module, &imports); -let mut env_mut = env.as_mut(&mut store); -env_mut.memory = Some(instance.exports.get_memory("memory")); -env_mut.alloc_guest_memory = Some(instance.exports.get_typed_function("__alloc")); +let instance = Instance::new(&mut store, &module, &imports)?; +let mut env_mut = env.into_mut(&mut store); // change to a FunctionEnvMut +let (mut data_mut, mut store_mut) = env_mut.data_and_store_mut(); // grab data and a new store_mut +data_mut.memory = Some(instance.exports.get_memory("memory")?.clone()); +data_mut.alloc_guest_memory = Some(instance.exports.get_typed_function(&mut store_mut, "__alloc")?); ``` ### New `MemoryView` API (preparation for shared memory)