News for hackers. Stuff that matters.
Re:Moving from TypeScript to Rust / WebAssembly by codemac on Thursday July 09, 2020 @01:48AM (#23777289)
As a complete noob to rust, I found attempting to manage a memory pool that is handed out per request to cause all kinds of borrow checking headaches.

My bet is people choose to allocate heavily rather than figure out how to share memory correctly with Rust. I need to learn more rust to get a hang of it so I don't allocate so much.

Are there any rust folks who have a great "list of memory management models for rust"?

Re:Moving from TypeScript to Rust / WebAssembly by zozbot234 on Thursday July 09, 2020 @05:27AM (#23778415)
Rust does not yet have local custom allocators ala C++. (You can change the global allocator, but this doesn't help the "memory arena" use case.) The feature is very much on the roadmap, though.
Re:Moving from TypeScript to Rust / WebAssembly by steveklabnik on Thursday July 09, 2020 @09:06AM (#23779742)
While this is true, this doesn't inherently mean you can't do this pattern. https://crates.io/crates/typed_arena for example. It depends on exactly how allocations and your data structure are tied together.
Re:Moving from TypeScript to Rust / WebAssembly by laurencerowe on Thursday July 09, 2020 @11:08AM (#23781082)
It would be amazingly handy if someday it was possible to direct Rust to make all heap allocations under a certain block within an arena. At the moment it looks like you have to rewrite any third party code that makes heap allocations to use the arena explicitly at each allocation.
Re:Moving from TypeScript to Rust / WebAssembly by steveklabnik on Thursday July 09, 2020 @11:27AM (#23781296)
Yep, it would. There’s certainly a bunch of work to do here still.