remove unnecessary read buf resizes
@@ -151,8 +151,7 @@ impl<'a> I2CMaster<'a> {
if address < 8 || address > 127 {
return Err(I2CError::InvalidAddress { address });
}
- let mut rbuf: Vec<u8> = vec![0; num_bytes];
- rbuf.resize(num_bytes, 0u8);
+ let mut rbuf: Vec<u8> = vec![0u8; num_bytes];
match i2c::i2c_read(self.i2c_ptr, address, rbuf.as_mut_ptr(), num_bytes) {
i2c::I2CStatus::Success => Ok(rbuf),
i2c::I2CStatus::Failure => Err(I2CError::UnknownAddress { address }),
@@ -192,8 +191,7 @@ impl<'a> I2CMaster<'a> {
tx_data: &[u8],
rx_len: usize,
) -> Result<Vec<u8>, I2CError> {
- let mut rbuf: Vec<u8> = vec![0; rx_len];
- rbuf.resize(rx_len, 0u8);
+ let mut rbuf: Vec<u8> = vec![0u8; rx_len];
match i2c::i2c_transaction(
self.i2c_ptr,
address,
