Closed rubberduck203 closed 4 years ago
This is the right thing to do for sure, but I've run into a small limitation.
One is allowed to write
let sw = 5.into_active_low_switch();
which hardly seems ideal. Of course subsequent method calls fail when attempted on sw
, but I feel like creating the instance should be forbidden in the first place.
Or do we need to somehow constrain IoPin
in Switch
itself?
which hardly seems ideal
Indeed.
Or do we need to somehow constrain IoPin in Switch itself?
Regardless of whether or not it solves this issue, yes. I attempted it before, but ran into “implicit dyn
is deprecated” errors and later, “duplicate implementation” issues. I think your PR helped me understand the prior, so I can take another stab at it.
I think I’ll merge this and track it in another issue. Thank you for the review!
Or do we need to somehow constrain IoPin in Switch itself?
Yes. Yes we do. This compiles just fine.
let switch = Switch::<_, ActiveHigh>::new(5);
But when then later fail when it the compiler fails to find a trait impl for Switch::<i32, ActiveHigh>
.
@dzarda what do you think of this?