Writing an OS in Rust: Heap Allocation
os.phil-opp.com
os.phil-opp.com
Note that in Rust today we can only use standard collection with the global allocator. https://github.com/phil-opp/blog_os/blob/post-10/src/main.rs... in the blog post it is intialized, and there's nothing to prevent allocation earlier and that will fail.
But there is work in progress (first https://github.com/rust-lang/rust/pull/58457) that will allow using local allocators, removing the ambient authority that makes that failure possible. Note that this doesn't mean a runtime cost. One can pass around a zero-sized token that is completely erased.
Yes, I'm eagerly awaiting https://github.com/rust-lang/rust/pull/58457 and your follow-up https://github.com/rust-lang/rust/pull/60703. AFAIK, a global allocator is still required with them (so we still have to initialize it), but it allows us to choose a different allocator for some collections, e.g. to avoid deadlocks in interrupt handlers.