Std::collections in a !#[no_std] crate when having a heap


I am planning a project which will run in a very strange environment without a proper c library. Therefore it is a !#[no_std] crate. However, I have a heap. Is it possible to have only core + std::collection by somehow supplying a memory allocator or is it a all or nothing deal?


You can use the alloc crate, this is currently unstable but under consideration for stabilisation. I’m not sure of any good introductory documentation for using it currently (hopefully if someone else knows they can link it).


The Rust Embedded Book spents a hole chapter on using collections in #[no_std] environment. I think that’s a good strating point. There are alternatives mentioned, too.


Thanks this is exactly what I was looking for. Could not find that chapter via google for some reason.