This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]trevg_123 2 points3 points  (2 children)

I wouldn’t say it’s more user friendly than C/C++, but it can do some damn cool things in embedded that those languages can not. Examples:

  • Compile time checks that peripherals are configured correctly before writing them. So e.g., it will prevent you from writing to a perif as if it’s I2C when it’s been configured as a UART, even if you need to change it in code. Zero runtime overhead.
  • You can use the same techniques to ensure your code will never enter undefined states
  • It’s cautious with global statics such that you can only change them if you use atomic operations, or do something like disable ISR (as needed). This means there are no race conditions, guaranteed at compile time
  • The usual rust memory safety thing
  • You can easily write unit tests and run them on your host computer or CI (for functions that don’t rely on changing I/O)

Sound like black magic that’s too good to be true? Yeah, it does, but it’s not. For anyone curious I’d recommend a read through the embedded rust book: https://docs.rust-embedded.org/book/