Skip to content

Commit 9ac61a7

Browse files
committed
Add + ?Sized to all blanket impls.
1 parent 64b66b5 commit 9ac61a7

File tree

12 files changed

+24
-23
lines changed

12 files changed

+24
-23
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
2+
resolver = "2"
23

34
# CI removes lines containing 'nightly-only' when not building with nightly.
45
members = [

embedded-hal-async/src/delay.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub trait DelayUs {
1313

1414
impl<T> DelayUs for &mut T
1515
where
16-
T: DelayUs,
16+
T: DelayUs + ?Sized,
1717
{
1818
async fn delay_us(&mut self, us: u32) {
1919
T::delay_us(self, us).await

embedded-hal-async/src/digital.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait Wait: embedded_hal::digital::ErrorType {
4848
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error>;
4949
}
5050

51-
impl<T: Wait> Wait for &mut T {
51+
impl<T: Wait + ?Sized> Wait for &mut T {
5252
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
5353
T::wait_for_high(self).await
5454
}

embedded-hal-async/src/i2c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
122122
) -> Result<(), Self::Error>;
123123
}
124124

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

embedded-hal-async/src/spi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
7676
}
7777
}
7878

79-
impl<Word: Copy + 'static, T: SpiDevice<Word>> SpiDevice<Word> for &mut T {
79+
impl<Word: Copy + 'static, T: SpiDevice<Word> + ?Sized> SpiDevice<Word> for &mut T {
8080
async fn transaction(
8181
&mut self,
8282
operations: &mut [Operation<'_, Word>],
@@ -149,7 +149,7 @@ pub trait SpiBus<Word: 'static + Copy = u8>: ErrorType {
149149
async fn flush(&mut self) -> Result<(), Self::Error>;
150150
}
151151

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

embedded-hal-nb/src/serial.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub trait ErrorType {
6969
type Error: Error;
7070
}
7171

72-
impl<T: ErrorType> ErrorType for &mut T {
72+
impl<T: ErrorType + ?Sized> ErrorType for &mut T {
7373
type Error = T::Error;
7474
}
7575

@@ -82,7 +82,7 @@ pub trait Read<Word: Copy = u8>: ErrorType {
8282
fn read(&mut self) -> nb::Result<Word, Self::Error>;
8383
}
8484

85-
impl<T: Read<Word>, Word: Copy> Read<Word> for &mut T {
85+
impl<T: Read<Word> + ?Sized, Word: Copy> Read<Word> for &mut T {
8686
fn read(&mut self) -> nb::Result<Word, Self::Error> {
8787
T::read(self)
8888
}
@@ -97,7 +97,7 @@ pub trait Write<Word: Copy = u8>: ErrorType {
9797
fn flush(&mut self) -> nb::Result<(), Self::Error>;
9898
}
9999

100-
impl<T: Write<Word>, Word: Copy> Write<Word> for &mut T {
100+
impl<T: Write<Word> + ?Sized, Word: Copy> Write<Word> for &mut T {
101101
fn write(&mut self, word: Word) -> nb::Result<(), Self::Error> {
102102
T::write(self, word)
103103
}

embedded-hal-nb/src/spi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub trait FullDuplex<Word: Copy = u8>: ErrorType {
3131
fn write(&mut self, word: Word) -> nb::Result<(), Self::Error>;
3232
}
3333

34-
impl<T: FullDuplex<Word>, Word: Copy> FullDuplex<Word> for &mut T {
34+
impl<T: FullDuplex<Word> + ?Sized, Word: Copy> FullDuplex<Word> for &mut T {
3535
fn read(&mut self) -> nb::Result<Word, Self::Error> {
3636
T::read(self)
3737
}

embedded-hal/src/delay.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait DelayUs {
1818

1919
impl<T> DelayUs for &mut T
2020
where
21-
T: DelayUs,
21+
T: DelayUs + ?Sized,
2222
{
2323
fn delay_us(&mut self, us: u32) {
2424
T::delay_us(self, us)

embedded-hal/src/digital.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ pub trait ErrorType {
5555
type Error: Error;
5656
}
5757

58-
impl<T: ErrorType> ErrorType for &T {
58+
impl<T: ErrorType + ?Sized> ErrorType for &T {
5959
type Error = T::Error;
6060
}
6161

62-
impl<T: ErrorType> ErrorType for &mut T {
62+
impl<T: ErrorType + ?Sized> ErrorType for &mut T {
6363
type Error = T::Error;
6464
}
6565

@@ -139,7 +139,7 @@ pub trait OutputPin: ErrorType {
139139
}
140140
}
141141

142-
impl<T: OutputPin> OutputPin for &mut T {
142+
impl<T: OutputPin + ?Sized> OutputPin for &mut T {
143143
fn set_low(&mut self) -> Result<(), Self::Error> {
144144
T::set_low(self)
145145
}
@@ -166,7 +166,7 @@ pub trait StatefulOutputPin: OutputPin {
166166
fn is_set_low(&self) -> Result<bool, Self::Error>;
167167
}
168168

169-
impl<T: StatefulOutputPin> StatefulOutputPin for &mut T {
169+
impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
170170
fn is_set_high(&self) -> Result<bool, Self::Error> {
171171
T::is_set_high(self)
172172
}
@@ -182,7 +182,7 @@ pub trait ToggleableOutputPin: ErrorType {
182182
fn toggle(&mut self) -> Result<(), Self::Error>;
183183
}
184184

185-
impl<T: ToggleableOutputPin> ToggleableOutputPin for &mut T {
185+
impl<T: ToggleableOutputPin + ?Sized> ToggleableOutputPin for &mut T {
186186
fn toggle(&mut self) -> Result<(), Self::Error> {
187187
T::toggle(self)
188188
}
@@ -197,7 +197,7 @@ pub trait InputPin: ErrorType {
197197
fn is_low(&self) -> Result<bool, Self::Error>;
198198
}
199199

200-
impl<T: InputPin> InputPin for &T {
200+
impl<T: InputPin + ?Sized> InputPin for &T {
201201
fn is_high(&self) -> Result<bool, Self::Error> {
202202
T::is_high(self)
203203
}

embedded-hal/src/i2c.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub trait ErrorType {
249249
type Error: Error;
250250
}
251251

252-
impl<T: ErrorType> ErrorType for &mut T {
252+
impl<T: ErrorType + ?Sized> ErrorType for &mut T {
253253
type Error = T::Error;
254254
}
255255

@@ -372,7 +372,7 @@ pub trait I2c<A: AddressMode = SevenBitAddress>: ErrorType {
372372
) -> Result<(), Self::Error>;
373373
}
374374

375-
impl<A: AddressMode, T: I2c<A>> I2c<A> for &mut T {
375+
impl<A: AddressMode, T: I2c<A> + ?Sized> I2c<A> for &mut T {
376376
fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> {
377377
T::read(self, address, read)
378378
}

embedded-hal/src/pwm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub trait ErrorType {
5353
type Error: Error;
5454
}
5555

56-
impl<T: ErrorType> ErrorType for &mut T {
56+
impl<T: ErrorType + ?Sized> ErrorType for &mut T {
5757
type Error = T::Error;
5858
}
5959

@@ -101,7 +101,7 @@ pub trait SetDutyCycle: ErrorType {
101101
}
102102
}
103103

104-
impl<T: SetDutyCycle> SetDutyCycle for &mut T {
104+
impl<T: SetDutyCycle + ?Sized> SetDutyCycle for &mut T {
105105
fn get_max_duty_cycle(&self) -> u16 {
106106
T::get_max_duty_cycle(self)
107107
}

embedded-hal/src/spi.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ pub trait ErrorType {
288288
type Error: Error;
289289
}
290290

291-
impl<T: ErrorType> ErrorType for &mut T {
291+
impl<T: ErrorType + ?Sized> ErrorType for &mut T {
292292
type Error = T::Error;
293293
}
294294

@@ -378,7 +378,7 @@ pub trait SpiDevice<Word: Copy + 'static = u8>: ErrorType {
378378
}
379379
}
380380

381-
impl<Word: Copy + 'static, T: SpiDevice<Word>> SpiDevice<Word> for &mut T {
381+
impl<Word: Copy + 'static, T: SpiDevice<Word> + ?Sized> SpiDevice<Word> for &mut T {
382382
fn transaction(&mut self, operations: &mut [Operation<'_, Word>]) -> Result<(), Self::Error> {
383383
T::transaction(self, operations)
384384
}
@@ -448,7 +448,7 @@ pub trait SpiBus<Word: Copy + 'static = u8>: ErrorType {
448448
fn flush(&mut self) -> Result<(), Self::Error>;
449449
}
450450

451-
impl<T: SpiBus<Word>, Word: Copy + 'static> SpiBus<Word> for &mut T {
451+
impl<T: SpiBus<Word> + ?Sized, Word: Copy + 'static> SpiBus<Word> for &mut T {
452452
fn read(&mut self, words: &mut [Word]) -> Result<(), Self::Error> {
453453
T::read(self, words)
454454
}

0 commit comments

Comments
 (0)