Skip to content

Commit c2830f1

Browse files
bors[bot]Dirbaio
andauthored
Merge #372
372: async/digital: add blanket impl for &mut T r=eldruin a=Dirbaio For some reason, I forgot to add it! :D Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents c80e9d9 + edae01e commit c2830f1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

embedded-hal-async/src/digital.rs

+32
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,35 @@ pub trait Wait: embedded_hal::digital::ErrorType {
7474
/// Wait for the pin to undergo any transition, i.e low to high OR high to low.
7575
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a>;
7676
}
77+
78+
impl<T: Wait> Wait for &mut T {
79+
type WaitForHighFuture<'a> = T::WaitForHighFuture<'a> where Self: 'a;
80+
81+
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
82+
T::wait_for_high(self)
83+
}
84+
85+
type WaitForLowFuture<'a> = T::WaitForLowFuture<'a> where Self: 'a;
86+
87+
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
88+
T::wait_for_low(self)
89+
}
90+
91+
type WaitForRisingEdgeFuture<'a> = T::WaitForRisingEdgeFuture<'a> where Self: 'a;
92+
93+
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
94+
T::wait_for_rising_edge(self)
95+
}
96+
97+
type WaitForFallingEdgeFuture<'a> = T::WaitForFallingEdgeFuture<'a> where Self: 'a;
98+
99+
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
100+
T::wait_for_falling_edge(self)
101+
}
102+
103+
type WaitForAnyEdgeFuture<'a> = T::WaitForAnyEdgeFuture<'a> where Self: 'a;
104+
105+
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
106+
T::wait_for_any_edge(self)
107+
}
108+
}

0 commit comments

Comments
 (0)