Skip to content

Commit

Permalink
Remove feature(impl_trait_projections) from async traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Sep 7, 2023
1 parent 030a232 commit 38ad4a6
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
10 changes: 5 additions & 5 deletions embedded-hal-async/src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ pub trait Wait: embedded_hal::digital::ErrorType {

impl<T: Wait + ?Sized> Wait for &mut T {
#[inline]
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
async fn wait_for_high(&mut self) -> Result<(), T::Error> {
T::wait_for_high(self).await
}

#[inline]
async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
async fn wait_for_low(&mut self) -> Result<(), T::Error> {
T::wait_for_low(self).await
}

#[inline]
async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_rising_edge(&mut self) -> Result<(), T::Error> {
T::wait_for_rising_edge(self).await
}

#[inline]
async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_falling_edge(&mut self) -> Result<(), T::Error> {
T::wait_for_falling_edge(self).await
}

#[inline]
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
async fn wait_for_any_edge(&mut self) -> Result<(), T::Error> {
T::wait_for_any_edge(self).await
}
}
8 changes: 4 additions & 4 deletions embedded-hal-async/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {

impl<A: AddressMode, T: I2c<A> + ?Sized> I2c<A> for &mut T {
#[inline]
async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), T::Error> {
T::read(self, address, read).await
}

#[inline]
async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> {
async fn write(&mut self, address: A, write: &[u8]) -> Result<(), T::Error> {
T::write(self, address, write).await
}

Expand All @@ -142,7 +142,7 @@ impl<A: AddressMode, T: I2c<A> + ?Sized> I2c<A> for &mut T {
address: A,
write: &[u8],
read: &mut [u8],
) -> Result<(), Self::Error> {
) -> Result<(), T::Error> {
T::write_read(self, address, write, read).await
}

Expand All @@ -151,7 +151,7 @@ impl<A: AddressMode, T: I2c<A> + ?Sized> I2c<A> for &mut T {
&mut self,
address: A,
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error> {
) -> Result<(), T::Error> {
T::transaction(self, address, operations).await
}
}
2 changes: 1 addition & 1 deletion embedded-hal-async/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]
#![no_std]
#![feature(async_fn_in_trait, impl_trait_projections)]
#![feature(async_fn_in_trait)]

pub mod delay;
pub mod digital;
Expand Down
20 changes: 10 additions & 10 deletions embedded-hal-async/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ impl<Word: Copy + 'static, T: SpiDevice<Word> + ?Sized> SpiDevice<Word> for &mut
async fn transaction(
&mut self,
operations: &mut [Operation<'_, Word>],
) -> Result<(), Self::Error> {
) -> Result<(), T::Error> {
T::transaction(self, operations).await
}

#[inline]
async fn read(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> {
async fn read(&mut self, buf: &mut [Word]) -> Result<(), T::Error> {
T::read(self, buf).await
}

#[inline]
async fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error> {
async fn write(&mut self, buf: &[Word]) -> Result<(), T::Error> {
T::write(self, buf).await
}

#[inline]
async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), Self::Error> {
async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), T::Error> {
T::transfer(self, read, write).await
}

#[inline]
async fn transfer_in_place(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> {
async fn transfer_in_place(&mut self, buf: &mut [Word]) -> Result<(), T::Error> {
T::transfer_in_place(self, buf).await
}
}
Expand Down Expand Up @@ -154,27 +154,27 @@ pub trait SpiBus<Word: 'static + Copy = u8>: ErrorType {

impl<T: SpiBus<Word> + ?Sized, Word: 'static + Copy> SpiBus<Word> for &mut T {
#[inline]
async fn read(&mut self, words: &mut [Word]) -> Result<(), Self::Error> {
async fn read(&mut self, words: &mut [Word]) -> Result<(), T::Error> {
T::read(self, words).await
}

#[inline]
async fn write(&mut self, words: &[Word]) -> Result<(), Self::Error> {
async fn write(&mut self, words: &[Word]) -> Result<(), T::Error> {
T::write(self, words).await
}

#[inline]
async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), Self::Error> {
async fn transfer(&mut self, read: &mut [Word], write: &[Word]) -> Result<(), T::Error> {
T::transfer(self, read, write).await
}

#[inline]
async fn transfer_in_place(&mut self, words: &mut [Word]) -> Result<(), Self::Error> {
async fn transfer_in_place(&mut self, words: &mut [Word]) -> Result<(), T::Error> {
T::transfer_in_place(self, words).await
}

#[inline]
async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), T::Error> {
T::flush(self).await
}
}
2 changes: 1 addition & 1 deletion embedded-hal-bus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(feature = "async", feature(async_fn_in_trait, impl_trait_projections))]
#![cfg_attr(feature = "async", feature(async_fn_in_trait))]

// needed to prevent defmt macros from breaking, since they emit code that does `defmt::blahblah`.
#[cfg(feature = "defmt-03")]
Expand Down
2 changes: 1 addition & 1 deletion embedded-io-adapters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(
any(feature = "tokio-1", feature = "futures-03"),
feature(async_fn_in_trait, impl_trait_projections)
feature(async_fn_in_trait)
)]
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
Expand Down
4 changes: 2 additions & 2 deletions embedded-io-async/src/impls/slice_mut.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Write;
use core::mem;
use core::{convert::Infallible, mem};

/// Write is implemented for `&mut [u8]` by copying into the slice, overwriting
/// its data.
Expand All @@ -12,7 +12,7 @@ use core::mem;
/// kind `ErrorKind::WriteZero`.
impl Write for &mut [u8] {
#[inline]
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, Infallible> {
let amt = core::cmp::min(buf.len(), self.len());
let (a, b) = mem::take(self).split_at_mut(amt);
a.copy_from_slice(&buf[..amt]);
Expand Down
6 changes: 4 additions & 2 deletions embedded-io-async/src/impls/slice_ref.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::convert::Infallible;

use crate::{BufRead, Read};

/// Read is implemented for `&[u8]` by copying from the slice.
Expand All @@ -6,7 +8,7 @@ use crate::{BufRead, Read};
/// The slice will be empty when EOF is reached.
impl Read for &[u8] {
#[inline]
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Infallible> {
let amt = core::cmp::min(buf.len(), self.len());
let (a, b) = self.split_at(amt);

Expand All @@ -26,7 +28,7 @@ impl Read for &[u8] {

impl BufRead for &[u8] {
#[inline]
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
async fn fill_buf(&mut self) -> Result<&[u8], Infallible> {
Ok(*self)
}

Expand Down
12 changes: 6 additions & 6 deletions embedded-io-async/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_fn_in_trait, impl_trait_projections)]
#![feature(async_fn_in_trait)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs)]
Expand Down Expand Up @@ -159,13 +159,13 @@ pub trait Seek: ErrorType {

impl<T: ?Sized + Read> Read for &mut T {
#[inline]
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, T::Error> {
T::read(self, buf).await
}
}

impl<T: ?Sized + BufRead> BufRead for &mut T {
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> {
async fn fill_buf(&mut self) -> Result<&[u8], T::Error> {
T::fill_buf(self).await
}

Expand All @@ -176,19 +176,19 @@ impl<T: ?Sized + BufRead> BufRead for &mut T {

impl<T: ?Sized + Write> Write for &mut T {
#[inline]
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
async fn write(&mut self, buf: &[u8]) -> Result<usize, T::Error> {
T::write(self, buf).await
}

#[inline]
async fn flush(&mut self) -> Result<(), Self::Error> {
async fn flush(&mut self) -> Result<(), T::Error> {
T::flush(self).await
}
}

impl<T: ?Sized + Seek> Seek for &mut T {
#[inline]
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Self::Error> {
async fn seek(&mut self, pos: SeekFrom) -> Result<u64, T::Error> {
T::seek(self, pos).await
}
}

0 comments on commit 38ad4a6

Please sign in to comment.