expression
Reacquire a host view after memory growth
When ordinary nonshared Wasm memory grows through the JavaScript API, old ArrayBuffer views are detached; recreate them using the current buffer. Shared memory uses different buffer behavior. This Rust Vec model deliberately reacquires a borrow after growth; it is not the JavaScript detachment mechanism. The separate Node lab tests real nonshared memory. Expected host stdout (not executed): before: 1 after: 3 Common mistake: Caching a typed array across guest calls that may grow memory.
Formal Syntax & Structure
rust syntaxrust
memory.grow(n); new Uint8Array(memory.buffer) (JavaScript API)Working Example
Example Snippetrust
fn main() { let mut region = vec![7u8]; { let view = ®ion[..]; println!("before: {}", view.len()); } region.extend([8, 9]); let view = ®ion[..]; println!("after: {}", view.len());}