Is there anything that can be done to make rust embedded less bad?
I have not done any rust embedded programming myself, so this is going off of my friend's experience and my own research.
So my friend was trying to write a driver for a dot matrix display he bought for fun, but he was having what seemed like a trivial problem with \embedded-hal\\. He has a whole bunch GPIO pins to drive the display and he wants to put them into an array.
OutputPin represents whatever the type would be of this GPIO array
However, this is not possible since each of these pins are different types (all implement the same trait) and the \dyn\\ keyword is disallowed on embedded. These two articles (first, second) give a lot of context about a very similar issue. Here is the fundamental issue as described in a quote:
The immediately obvious drawback of typestates is that no matter how closely related the pins, in the eyes of the compiler they are different types. This means you're not going to have an easy time collecting them into an array or iterating over them unless you want to bring dynamic dispatch into the mix, which at this level... Let's just say it's a bit of a bull in a china shop situation.
I spent the better part of the day trying to think of workarounds and have come to the conclusion that either you can proceed like lose a lot of safety for convenience, or have compile time checking but suffer.
I cannot think how anyone realistically can program without iteration of pins if you go with the comp-time checking, so in my eyes, this significantly de-legitimizes rust as an embedded language for me.
I want to understand how people actually deal with this and/or if there are any language changes that could potentially address this issue. This is beyond my expertise and would appreciate any thoughts.