I really like this heapless
. It sort of helps to implement my strategy for developing Rust programs:
1.Maximize no_std
surface. 2 Minimize heap allocations.
It is easier to see then the hot zones where the program actually dynamically grows for a good reason, similarly as with unsafe
blocks it is easy to the red zones for memory errors. This helps a lot with availability and protection against denial-of-service (DoS) attacks.
So to summarize I don’t split Rust program in my mind just to “unsafe” and “safe” but instead I split it “unsafe”, “static” and “dynamic”, or along the lines.
Pretty easy way to implement this strategy: avoid using Vec
to the extremes. It is quite common in Rust programs that there’s tons of Vec
instances, while in reality most of them are fixed arrays on their usage patterns. In addition heapless
provides pretty nice set of structures for common tasks with a fixed amount data space.