I'd appreciate ideas to port C code to idiomatic Rust, given a no-heap usage constraint.
I'm looking into using Rust for a (re)implementation of a deep embedded project. Due to safety restrictions (automotive and more) I am not allowed to do any heap allocations.
In the original C code, a device tree is built from a collection of static structs that reference each other; each driver and each instance is represented by a struct; driver classes are represented by a struct with function pointers which can be implemented by specific drivers which implement these functions. Attached below is a link to this C code (simplified, as the original code makes heave use of the preprocessor to do the boilerplating)
I guess using traits and boxing would be the idiomatic way to build a tree like this in Rust; I made this work without problems, but given the no-heap constraints this solution is not usable at this time.
My efforts to make a dumb port from the C code end up in very nasty code: full of unsafes, and in the end not even compiling because of the error "mutable references are not allowed in the final value of statics".
I would appreciate any hints on how to port the original C code to idiomatic Rust, working within the same constraints of using no heap memory.
Thanks, and apologies for the messy nature of this question.