Hacker News new | past | comments | ask | show | jobs | submit login

It's not done here, but I've had success returning/accepting pointers over the Rust/JS boundary [0] using Box w/ raw pointers and mem::forget as necessary. They are just JS ints to places in the mem array like the mem refs in this blog. This can help you not require the "Cpu" instance as a static singleton but instead instantiate it as needed.

0 - https://github.com/cretz/asmble/blob/master/examples/rust-re...




Yeah I've used malloc+free+forget as well to allocate multi-megabyte strings (JSON encoded objects) to exchange data between JS and rust. Seems to work a treat.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: