Closed
Description
I found one ugly side effect of the &mut
blanket impls while experimenting updating stm32f4xx-hal's GPIO.
it's making the trait methods take priority over the inherent methods in some cases: Dirbaio/stm32f4xx-hal@091d945#diff-a49fe1ed5910761241be27a9c10bb8e11cac30ec0a80b839278ae3a1630384bcR102
It seems to be a consequence of the autoderef rules: rust-lang/rust#26007 . It happens when you mix &self
with &mut self
. Since the blanket impl is for &mut self
, it matches "first" before Rust tries to autoderef.
I don't think this is especially bad. It might be annoying in HAL code, but non-generic end user code won't be importing the traits if they're indending to call inherent methods.
What should we do?
- Change StatefulOutputPin to require &mut self
- Remove that blanket impl.
- Nothing.
Metadata
Metadata
Assignees
Labels
No labels