i2c: remove useless lifetimes.

This commit is contained in:
Dario Nieuwenhuis
2023-03-08 01:29:29 +01:00
parent f43ab6e0ef
commit 6236f2baf1
2 changed files with 24 additions and 24 deletions

View File

@@ -41,7 +41,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
/// - `MAK` = master acknowledge
/// - `NMAK` = master no acknowledge
/// - `SP` = stop condition
async fn read<'a>(&'a mut self, address: A, read: &'a mut [u8]) -> Result<(), Self::Error>;
async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error>;
/// Writes bytes to slave with address `address`
///
@@ -59,7 +59,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
/// - `SAK` = slave acknowledge
/// - `Bi` = ith byte of data
/// - `SP` = stop condition
async fn write<'a>(&'a mut self, address: A, write: &'a [u8]) -> Result<(), Self::Error>;
async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>;
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `read` *in a
/// single transaction*.
@@ -83,11 +83,11 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
/// - `MAK` = master acknowledge
/// - `NMAK` = master no acknowledge
/// - `SP` = stop condition
async fn write_read<'a>(
&'a mut self,
async fn write_read(
&mut self,
address: A,
write: &'a [u8],
read: &'a mut [u8],
write: &[u8],
read: &mut [u8],
) -> Result<(), Self::Error>;
/// Execute the provided operations on the I2C bus as a single transaction.
@@ -103,35 +103,35 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
/// - `SAD+R/W` = slave address followed by bit 1 to indicate reading or 0 to indicate writing
/// - `SR` = repeated start condition
/// - `SP` = stop condition
async fn transaction<'a, 'b>(
&'a mut self,
async fn transaction(
&mut self,
address: A,
operations: &'a mut [Operation<'b>],
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error>;
}
impl<A: AddressMode, T: I2c<A>> I2c<A> for &mut T {
async fn read<'a>(&'a mut self, address: A, buffer: &'a mut [u8]) -> Result<(), Self::Error> {
async fn read(&mut self, address: A, buffer: &mut [u8]) -> Result<(), Self::Error> {
T::read(self, address, buffer).await
}
async fn write<'a>(&'a mut self, address: A, bytes: &'a [u8]) -> Result<(), Self::Error> {
async fn write(&mut self, address: A, bytes: &[u8]) -> Result<(), Self::Error> {
T::write(self, address, bytes).await
}
async fn write_read<'a>(
&'a mut self,
async fn write_read(
&mut self,
address: A,
bytes: &'a [u8],
buffer: &'a mut [u8],
bytes: &[u8],
buffer: &mut [u8],
) -> Result<(), Self::Error> {
T::write_read(self, address, bytes, buffer).await
}
async fn transaction<'a, 'b>(
&'a mut self,
async fn transaction(
&mut self,
address: A,
operations: &'a mut [Operation<'b>],
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error> {
T::transaction(self, address, operations).await
}

View File

@@ -41,7 +41,7 @@
//! // ...
//! # Ok(())
//! }
//! fn transaction<'a>(&mut self, address: u8, operations: &mut [Operation<'a>]) -> Result<(), Self::Error> {
//! fn transaction(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
//! // ...
//! # Ok(())
//! }
@@ -61,7 +61,7 @@
//! // ...
//! # Ok(())
//! }
//! fn transaction<'a>(&mut self, address: u16, operations: &mut [Operation<'a>]) -> Result<(), Self::Error> {
//! fn transaction(&mut self, address: u16, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> {
//! // ...
//! # Ok(())
//! }
@@ -325,10 +325,10 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
/// - `SAD+R/W` = slave address followed by bit 1 to indicate reading or 0 to indicate writing
/// - `SR` = repeated start condition
/// - `SP` = stop condition
fn transaction<'a>(
fn transaction(
&mut self,
address: A,
operations: &mut [Operation<'a>],
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error>;
}
@@ -350,10 +350,10 @@ impl<A: AddressMode, T: I2c<A>> I2c<A> for &mut T {
T::write_read(self, address, bytes, buffer)
}
fn transaction<'a>(
fn transaction(
&mut self,
address: A,
operations: &mut [Operation<'a>],
operations: &mut [Operation<'_>],
) -> Result<(), Self::Error> {
T::transaction(self, address, operations)
}