From e8e44413d387a8e134f5c04210b827e75905214d Mon Sep 17 00:00:00 2001 From: Jonah Dahlquist Date: Thu, 1 Aug 2019 08:38:42 -0500 Subject: [PATCH] Removed unnecessary generics from structs --- src/lib.rs | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7405ec1..f9c2d28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,13 +107,13 @@ pub enum ArpResponses { pub struct UninitializedSocket(Socket); pub struct UdpSocket(Socket); -pub struct W5500<'a, ChipSelectError, ChipSelect: OutputPin> { +pub struct W5500<'a, ChipSelect: OutputPin> { chip_select: &'a mut ChipSelect, sockets: u8, // each bit represents whether the corresponding socket is available for take } impl<'b, 'a: 'b, ChipSelectError, ChipSelect: OutputPin> - W5500<'a, ChipSelectError, ChipSelect> + W5500<'a, ChipSelect> { fn new(chip_select: &'a mut ChipSelect) -> Self { W5500 { @@ -122,14 +122,14 @@ impl<'b, 'a: 'b, ChipSelectError, ChipSelect: OutputPin } } - pub fn with_initialisation<'c, E, Spi: FullDuplex>( + pub fn with_initialisation<'c, SpiError, Spi: FullDuplex>( chip_select: &'a mut ChipSelect, spi: &'c mut Spi, wol: OnWakeOnLan, ping: OnPingRequest, mode: ConnectionType, arp: ArpResponses, - ) -> Result> { + ) -> Result> { let mut w5500 = Self::new(chip_select); { let mut w5500_active = w5500.activate(spi)?; @@ -151,33 +151,26 @@ impl<'b, 'a: 'b, ChipSelectError, ChipSelect: OutputPin } } - pub fn activate<'c, E, Spi: FullDuplex>( + pub fn activate<'c, SpiError, Spi: FullDuplex>( &'b mut self, spi: &'c mut Spi, - ) -> Result< - ActiveW5500<'b, 'a, 'c, E, ChipSelectError, ChipSelect, Spi>, - TransferError, - > { + ) -> Result, TransferError> + { Ok(ActiveW5500(self, spi)) } } -pub struct ActiveW5500< - 'a, - 'b: 'a, - 'c, - SpiError, - ChipSelectError, - ChipSelect: OutputPin, - Spi: FullDuplex, ->(&'a mut W5500<'b, ChipSelectError, ChipSelect>, &'c mut Spi); +pub struct ActiveW5500<'a, 'b: 'a, 'c, ChipSelect: OutputPin, Spi: FullDuplex>( + &'a mut W5500<'b, ChipSelect>, + &'c mut Spi, +); impl< - SpiError, ChipSelectError, ChipSelect: OutputPin, + SpiError, Spi: FullDuplex, - > ActiveW5500<'_, '_, '_, SpiError, ChipSelectError, ChipSelect, Spi> + > ActiveW5500<'_, '_, '_, ChipSelect, Spi> { pub fn take_socket(&mut self, socket: Socket) -> Option { self.0.take_socket(socket) @@ -407,13 +400,13 @@ pub trait IntoUdpSocket { } impl< - SpiError, ChipSelectError, ChipSelect: OutputPin, + SpiError, Spi: FullDuplex, > IntoUdpSocket for ( - &mut ActiveW5500<'_, '_, '_, SpiError, ChipSelectError, ChipSelect, Spi>, + &mut ActiveW5500<'_, '_, '_, ChipSelect, Spi>, UninitializedSocket, ) { @@ -456,10 +449,7 @@ impl< ChipSelect: OutputPin, Spi: FullDuplex, > Udp - for ( - &mut ActiveW5500<'_, '_, '_, SpiError, ChipSelectError, ChipSelect, Spi>, - &UdpSocket, - ) + for (&mut ActiveW5500<'_, '_, '_, ChipSelect, Spi>, &UdpSocket) { fn receive( &mut self,