3 ms·
MY_GPIO.borrow(cs).borrow().as_ref().unwrap().odr.modify(|_, w| w.odr1().set_bit()); or let mutex = MY_GPIO.borrow(cs).borrow().as_ref().unwrap(); mutex.odr
by capableweb 3y ago
MY_GPIO.borrow(cs).borrow().as_ref().unwrap().odr.modify(|_, w| w.odr1().set_bit());
or
let mutex = MY_GPIO.borrow(cs).borrow().as_ref().unwrap(); mutex.odr.modify(|_, w| w.odr1().set_bit());
Both of those ways are really horrible, and differ almost nothing. I understand and know why it looks like it does, but having to jump through all that mental gymnastics just to understand/write one line is why Rust is just overly verbose for a lot of things.
- FrustratedMonky 3y agoIs that one line more verbose than adding multiple lines of passing information through all the functions to provide all the same features? Probably not clear, but all of those functions are doing something that is helpful in additional checks. As others pointed out, you can set a pointer if you like in a simple line, but that isn't safe. The verbosity is providing the features, at least it is on one line, instead of 20 or 100 lines.
- capableweb 3y agoOf course the verbosity is doing something, the same is true for Java as well, it's not like the verbosity is just useless characters doing nothing. Still makes it overly verbose for a lot of us. I still write Rust code daily, but I wish the language thought a bit more about read/write ergonomics.
- oneshtein 3y agoIt's API, not a language. Write your own, ergonomic and safe API on top of unsafe code.
- capableweb 3y agoDon't act like this verbosity isn't widespread in the Rust ecosystem already.
- oneshtein 3y agoI'm a professional software developer. In my experience, Rust code is shorter than equivalent C or C++ code, with proper error handling, no memory leaks, no race conditions. If you rewrite the code above in a proper C, you will have a page of code at least.