Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by rhn_mk1 on Sunday March 07, 2021 @05:20AM
(#26374712)
Maybe defining a "Port" trait and using the dynamic type instead of the static one is a solution.
[ Parent
| on HN ]
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by rcxdude on Sunday March 07, 2021 @05:28AM
(#26374743)
Perhaps, but it sucks from a performance point of view. In embedded for a lot of operations you want the HAL to compile down to one or two instructions (GPIO being a classic example of this). Dynamic indirection is proportionally very expensive here (though in embedded a lot of the other costs normally associated with pointers are a lot less, since the memory hierarchy is very shallow).
Re:Why I rewrote my Rust keyboard firmware in Zig: consisten...
by pas on Sunday March 07, 2021 @07:09AM
(#26375253)
enum_dispatch to the rescue! (or at least that is what it says on the tin: https://docs.rs/enum_dispatch/0.3.5/enum_dispatch/ )