// Main function
#[arduino_uno::entry]
fn main() -> ! {
let peripherals = arduino_uno::Peripherals::take().unwrap();
let mut pins = arduino_uno::Pins::new(
peripherals.PORTB,
peripherals.PORTC,
peripherals.PORTD,
);
// Pin D13 is connected to L led
let mut led = pins.d13.into_output(&mut pins.ddr);
loop {
led.toggle().void_unwrap();
arduino_uno::delay_ms(500);
}
}
https://github.com/vlisivka/rust-arduino-blink/blob/main/src...Are you just noting specifics, or was it your experience that there was less Rust required for a full C to Rust conversion?
> If you need a data structure more complex than an array of something, C is stupidly verbose.
What’s stupidly verbose about Structs to you?
Every one of those things requires a fairly primitive function call that sometimes doesn't even need to exist in another language. For contrast, think about all the macrology that the Linux kernel does to iterate across every element of a linked list that is effectively "for element in list {}" in any higher language.
And, even worse, most of that stuff in C needs to be runtime-only, while some of this kind of thing gets elided by the compiler in other languages.
If you don't consider all that "stupidly verbose" I'm really curious what you would?
And this is long before we start talking about concurrency.
C allows you to write something that works "just enough" that you put it into production and then it bites you in the ass (similar to quadratic algorithms--functional enough to get to production and then bite you).
This is a fairly odd claim.
If you have to deal with strings (ASCII and UTF-8) properly, C is stupidly verbose.
If you need a data structure more complex than an array of something, C is stupidly verbose.
If you want to deal with pattern matching/regexen, C is ridiculously verbose.
Do I agree that Rust is far more verbose for an embedded "blinky" (the embedded equivalent of "Hello, World!")? Yes.
But once I start doing things like processing messages in a communications stack (BLE, CANOpen, Ethernet, etc.), Rust starts looking better and better.