Skip to content

Commit

Permalink
Use impl_trait_projections
Browse files Browse the repository at this point in the history
  • Loading branch information
rmja authored and eldruin committed May 25, 2023
1 parent 17e51e9 commit 3fddbf7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions embedded-storage-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![no_std]
#![feature(async_fn_in_trait)]
#![feature(impl_trait_projections)]
#![allow(incomplete_features)]

pub mod nor_flash;
14 changes: 3 additions & 11 deletions embedded-storage-async/src/nor_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ pub trait NorFlash: ReadNorFlash {
impl<T: ReadNorFlash> ReadNorFlash for &mut T {
const READ_SIZE: usize = T::READ_SIZE;

async fn read(
&mut self,
offset: u32,
bytes: &mut [u8],
) -> Result<(), <&mut T as ErrorType>::Error> {
async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
T::read(self, offset, bytes).await
}

Expand All @@ -69,15 +65,11 @@ impl<T: NorFlash> NorFlash for &mut T {
const WRITE_SIZE: usize = T::WRITE_SIZE;
const ERASE_SIZE: usize = T::ERASE_SIZE;

async fn erase(&mut self, from: u32, to: u32) -> Result<(), <&mut T as ErrorType>::Error> {
async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
T::erase(self, from, to).await
}

async fn write(
&mut self,
offset: u32,
bytes: &[u8],
) -> Result<(), <&mut T as ErrorType>::Error> {
async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
T::write(self, offset, bytes).await
}
}

0 comments on commit 3fddbf7

Please sign in to comment.