You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets say I have a struct which is supposed to store a generic SpiDevice:
structFoo<E>{device:Box<dynSpiDevice<Error = E>>}
I then want to store a device into it:
let f = Foo{device:Box::new(spi_device_value),};
This works with linux_embedded_hal but not with ftdi_embedded_hal, because it appears the SpiDevice trait is only implemented on references to SpiDevice<Device>.
I'm fairly new to rust, but it seems that simply implementing it for the struct directly works for both references and owned values:
Lets say I have a struct which is supposed to store a generic
SpiDevice
:I then want to store a device into it:
This works with
linux_embedded_hal
but not withftdi_embedded_hal
, because it appears theSpiDevice
trait is only implemented on references toSpiDevice<Device>
.I'm fairly new to rust, but it seems that simply implementing it for the struct directly works for both references and owned values:
I did this transformation (along with removing the one lifetime reference to 'a in the body, and it works just fine.
Is there a reason why it's only implemented for references?
It seems like you get the impl on &mut T for free:
https://rtic.rs/dev/api/embedded_hal/spi/trait.SpiDevice.html#impl-SpiDevice%3CWord%3E-for-%26mut+T
The text was updated successfully, but these errors were encountered: