Fix missing lifetime bounds

This commit is contained in:
Wilfried Chauveau 2021-11-21 08:11:00 +00:00
parent 8d108d8753
commit eac604accd
No known key found for this signature in database
GPG key ID: 0BC4C0B2B0879D6A
4 changed files with 36 additions and 12 deletions

View file

@ -109,7 +109,10 @@ impl<'d, T: GpioPin> InputPin for ExtiInput<'d, T> {
} }
impl<'d, T: GpioPin> WaitForRisingEdge for ExtiInput<'d, T> { impl<'d, T: GpioPin> WaitForRisingEdge for ExtiInput<'d, T> {
type Future<'a> = ExtiInputFuture<'a>; type Future<'a>
where
Self: 'a,
= ExtiInputFuture<'a>;
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::Future<'a> { fn wait_for_rising_edge<'a>(&'a mut self) -> Self::Future<'a> {
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false) ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false)
@ -117,7 +120,10 @@ impl<'d, T: GpioPin> WaitForRisingEdge for ExtiInput<'d, T> {
} }
impl<'d, T: GpioPin> WaitForFallingEdge for ExtiInput<'d, T> { impl<'d, T: GpioPin> WaitForFallingEdge for ExtiInput<'d, T> {
type Future<'a> = ExtiInputFuture<'a>; type Future<'a>
where
Self: 'a,
= ExtiInputFuture<'a>;
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::Future<'a> { fn wait_for_falling_edge<'a>(&'a mut self) -> Self::Future<'a> {
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true) ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true)
@ -125,7 +131,10 @@ impl<'d, T: GpioPin> WaitForFallingEdge for ExtiInput<'d, T> {
} }
impl<'d, T: GpioPin> WaitForAnyEdge for ExtiInput<'d, T> { impl<'d, T: GpioPin> WaitForAnyEdge for ExtiInput<'d, T> {
type Future<'a> = ExtiInputFuture<'a>; type Future<'a>
where
Self: 'a,
= ExtiInputFuture<'a>;
fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> { fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> {
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, true) ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, true)

View file

@ -1,7 +1,9 @@
use core::future::Future; use core::future::Future;
pub trait Delay { pub trait Delay {
type DelayFuture<'a>: Future<Output = ()> + 'a; type DelayFuture<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Future that completes after now + millis /// Future that completes after now + millis
fn delay_ms(&mut self, millis: u64) -> Self::DelayFuture<'_>; fn delay_ms(&mut self, millis: u64) -> Self::DelayFuture<'_>;

View file

@ -2,7 +2,9 @@ use core::future::Future;
/// Wait for a pin to become high. /// Wait for a pin to become high.
pub trait WaitForHigh { pub trait WaitForHigh {
type Future<'a>: Future<Output = ()> + 'a; type Future<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Wait for a pin to become high. /// Wait for a pin to become high.
/// ///
@ -13,7 +15,9 @@ pub trait WaitForHigh {
/// Wait for a pin to become low. /// Wait for a pin to become low.
pub trait WaitForLow { pub trait WaitForLow {
type Future<'a>: Future<Output = ()> + 'a; type Future<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Wait for a pin to become low. /// Wait for a pin to become low.
/// ///
@ -24,7 +28,9 @@ pub trait WaitForLow {
/// Wait for a rising edge (transition from low to high) /// Wait for a rising edge (transition from low to high)
pub trait WaitForRisingEdge { pub trait WaitForRisingEdge {
type Future<'a>: Future<Output = ()> + 'a; type Future<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Wait for a rising edge (transition from low to high) /// Wait for a rising edge (transition from low to high)
fn wait_for_rising_edge(&mut self) -> Self::Future<'_>; fn wait_for_rising_edge(&mut self) -> Self::Future<'_>;
@ -32,7 +38,9 @@ pub trait WaitForRisingEdge {
/// Wait for a falling edge (transition from high to low) /// Wait for a falling edge (transition from high to low)
pub trait WaitForFallingEdge { pub trait WaitForFallingEdge {
type Future<'a>: Future<Output = ()> + 'a; type Future<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Wait for a falling edge (transition from high to low) /// Wait for a falling edge (transition from high to low)
fn wait_for_falling_edge(&'_ mut self) -> Self::Future<'_>; fn wait_for_falling_edge(&'_ mut self) -> Self::Future<'_>;
@ -40,7 +48,9 @@ pub trait WaitForFallingEdge {
/// Wait for any edge (any transition, high to low or low to high) /// Wait for any edge (any transition, high to low or low to high)
pub trait WaitForAnyEdge { pub trait WaitForAnyEdge {
type Future<'a>: Future<Output = ()> + 'a; type Future<'a>: Future<Output = ()> + 'a
where
Self: 'a;
/// Wait for any edge (any transition, high to low or low to high) /// Wait for any edge (any transition, high to low or low to high)
fn wait_for_any_edge(&mut self) -> Self::Future<'_>; fn wait_for_any_edge(&mut self) -> Self::Future<'_>;

View file

@ -27,7 +27,8 @@ pub trait Spi<Word> {
pub trait FullDuplex<Word>: Spi<Word> + Write<Word> + Read<Word> { pub trait FullDuplex<Word>: Spi<Word> + Write<Word> + Read<Word> {
type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where where
Self: 'a; Self: 'a,
Word: 'a;
/// The `read` array must be at least as long as the `write` array, /// The `read` array must be at least as long as the `write` array,
/// but is guaranteed to only be filled with bytes equal to the /// but is guaranteed to only be filled with bytes equal to the
@ -42,7 +43,8 @@ pub trait FullDuplex<Word>: Spi<Word> + Write<Word> + Read<Word> {
pub trait Write<Word>: Spi<Word> { pub trait Write<Word>: Spi<Word> {
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where where
Self: 'a; Self: 'a,
Word: 'a;
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>; fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
} }
@ -50,7 +52,8 @@ pub trait Write<Word>: Spi<Word> {
pub trait Read<Word>: Write<Word> { pub trait Read<Word>: Write<Word> {
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where where
Self: 'a; Self: 'a,
Word: 'a;
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>; fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
} }