Methods like blocking::i2c::Read::read should take &mut [MaybeUninit<u8>] instead of &mut [u8] to allow for uninitialized buffers to be used.
For example:
pub trait Read<A: AddressMode = SevenBitAddress> {
type Error;
fn read(&mut self, address: A, buffer: &mut [u8]) -> Result<(), Self::Error>;
}
should become
pub trait Read<A: AddressMode = SevenBitAddress> {
type Error;
fn read<'a>(&mut self, address: A, buffer: &'a mut [MaybeUninit<u8>]) -> Result<&'a [u8], Self::Error>;
}
Since slices of maybe uninit can only be converted to slices of normal types through unsafe, the methods should return the initiated slice.
Issues raised in #286 apply, namely that the returned slice may refer to a subslice of the input buffer. If that's a safety issue, the traits should be made unsafe to enforce that invariant.
Methods like
blocking::i2c::Read::readshould take&mut [MaybeUninit<u8>]instead of&mut [u8]to allow for uninitialized buffers to be used.For example:
should become
Since slices of maybe uninit can only be converted to slices of normal types through unsafe, the methods should return the initiated slice.
Issues raised in #286 apply, namely that the returned slice may refer to a subslice of the input buffer. If that's a safety issue, the traits should be made unsafe to enforce that invariant.