5 ms·
> MY_GPIO.borrow(cs).borrow().as_ref().unwrap().odr.modify(|_, w| w.odr1().set_bit()); > I tried. I really tried. You gave up too soon. That's not particul
by biorach 3y ago
> MY_GPIO.borrow(cs).borrow().as_ref().unwrap().odr.modify(|_, w| w.odr1().set_bit());
> I tried. I really tried.
You gave up too soon.
That's not particularly gnarly rust. It's just chained method calls like in many other languages.
Admittedly the `borrow().borrow.as_ref().unwrap()` thing looks a bit excessive - does the book not explain it?
Overall the complexity here isn't the language - it's due to the implementation of the access to the GPIO bits.
- giancarlostoro 3y ago> That's not particularly gnarly rust. It's just chained method calls like in many other languages. That was my thought as well, as someone who is not Rust heavy (though I do small projects with it now and then), I get some of what's going on, and I've done a little bit of embedded, I could be misremembering but I don't remember it feeling this confusing or intimidating and that was using C, which to newcomers can be both. I'm really confused by this method chaining, I would argue its too confusing and breaking it up with comments might be best for newcomers.