Rust
General Notes
On the usage of impl Trait
impl Trait
is not intended as a replacement for dynamic dispatch (dyn Trait
).
It only allows you to write a placeholder for some types that are unrepresentable, like closures and iterators.
On creating config files
always have a version
field
- that never changes place.
- exists from the beginning of the versions of the config file.
- preferably at the top level of the file.
This way we can easily check if a config file is compatible with our parser.
It is also interesting to separate the config structure+parser in a crate, so we can use it’s version exclusively for this.
Embedded Rust
General Reminders
Implementing traits for all peripheral ‘kinds’ (as in peripherals that have the same function but different hardware implementations) eases migrating in the future from one implementation to the next and also allows you to implement virtual peripherals for testing without the real hardware.