Hi,
first of all, a disclaimer: I'm new to Rust, I haven't actually used Rust for embedded development yet, but I'm learning Rust already.
I have seen some very verbose abstractions used in embedded Rust-related blog posts, tutorials, etc. They are so verbose that it is actually quite difficult to understand what the code is doing at a glance, at least for me, coming from a C background.
For example, I saw this code in this blog post shared in this edition of TWIR (I am in no way or form attacking the author of this post, it's just the most recent place where I saw this kind of code).
/* Disables all wdt stages & the global watchdog flag itself */
rtccntl.wdtconfig0.modify(|_, w| unsafe {
w
.wdt_stg0()
.bits(0x0)
.wdt_stg1()
.bits(0x0)
.wdt_stg2()
.bits(0x0)
.wdt_stg3()
.bits(0x0)
.wdt_flashboot_mod_en()
.clear_bit()
.wdt_en()
.clear_bit()
});
Why isn't this just rtccntl.wdtconfig0 = 0x00
(or whatever the code is doing with the bits - I didn't really took the time to understand what's going on).
Is this verbose-kind of abstraction the best we can do in Embedded Rust?
Excuse my rant, but it's a bit worrying that single-line-of-code bit-masking operations are exploding to 14 lines of code.