diff --git a/src/digital/v2_compat.rs b/src/digital/v2_compat.rs index 779c089d3..bb5bae8b5 100644 --- a/src/digital/v2_compat.rs +++ b/src/digital/v2_compat.rs @@ -39,6 +39,9 @@ where } } +#[cfg(feature = "unproven")] +#[allow(deprecated)] +impl v2::toggleable::Default for T where T: v1::toggleable::Default {} /// Implementation of fallible `v2::InputPin` for `v1::InputPin` digital traits #[cfg(feature = "unproven")] @@ -81,6 +84,20 @@ mod tests { } } + #[allow(deprecated)] + impl v1::StatefulOutputPin for OldOutputPinImpl { + fn is_set_low(&self) -> bool { + self.state == false + } + + fn is_set_high(&self) -> bool { + self.state == true + } + } + + #[allow(deprecated)] + impl v1::toggleable::Default for OldOutputPinImpl {} + struct NewOutputPinConsumer { _pin: T, } @@ -92,6 +109,25 @@ mod tests { } } + struct NewToggleablePinConsumer { + _pin: T, + } + + impl NewToggleablePinConsumer + where + T: v2::ToggleableOutputPin, + { + pub fn new(pin: T) -> NewToggleablePinConsumer { + NewToggleablePinConsumer { _pin: pin } + } + } + + #[test] + fn v2_v1_toggleable_implicit() { + let i = OldOutputPinImpl { state: false }; + let _c = NewToggleablePinConsumer::new(i); + } + #[test] fn v2_v1_output_implicit() { let i = OldOutputPinImpl{state: false};