3 ms·
As others have explained, it's definitely possible to construct those data structures in Rust and use them from a crate. But you can't just flip a switch to get
by fnord123 10y ago
As others have explained, it's definitely possible to construct those data structures in Rust and use them from a crate. But you can't just flip a switch to get the standard library collections to work that way.
You could probably get pretty far by copy pasting the standard library containers you're interested in and replace Box with something like OffsetBox which uses indices into your memmap arena instead of pointers to any addressable memory. Of course, implementing OffsetBox is an exercise for the reader. :)
You would probably have to write some unsafe code to get it to work. But it's not a blocker for a project.
- amelius 10y agoPerhaps a solution would be to introduce the concept of relative pointers. I.e., the pointer becomes a signed value that should be added to the address of the pointer to obtain the address of the location pointed to. Not sure what the implications would be. Of course the standard data-structures would need to support such pointers. After some searching, I found that Microsoft Visual Studio supports something similar, and exactly for the application I had in mind: [1]. [1] https://msdn.microsoft.com/en-us/library/57a97k4e.aspx https://msdn.microsoft.com/en-us/library/57a97k4e.aspx