pub unsafe fn read_u16_unchecked(data: &[u8]) -> (u16, &[u8]) {
    let word = u16::from_be_bytes([*data.get_unchecked(0), *data.get_unchecked(1)]);

    //This is safe if data.len() > 2 as get_unchecked only invokes undefined behavior
    //if get would return none (idx > len)
    (word, data.get_unchecked(2..))
}
/// Reads an u16 from the given modbus data without performing bounds checks. The data is considered to be big endian with msB first.
Reads an u16 from the given modbus data without performing bounds checks. The data is considered to be big endian with msB first.
Reads an u16 from the given modbus data without performing bounds checks . The data is considered to be big endian with msB first .
pub unsafe fn read_u16_unchecked(data: &[u8]) -> (u16, &[u8]) {
    let word = u16::from_be_bytes([*data.get_unchecked(0), *data.get_unchecked(1)]);
    //This is safe if data.len() > 2 as get_unchecked only invokes undefined behavior
    //if get would return none (idx > len)
    (word, data.get_unchecked(2..))
}
pub unsafe fn read_u16_unchecked ( data : & [ u8 ] ) -> ( u16 , & [ u8 ] ) { let word = u16 :: from_be_bytes ( [ * data . get_unchecked ( 0 ) , * data . get_unchecked ( 1 ) ] ) ; //This is safe if data.len() > 2 as get_unchecked only invokes undefined behavior //if get would return none (idx > len) ( word , data . get_unchecked ( 2 .. ) ) }
Reads an u16 from the given modbus data without performing bounds checks.
Reads an u16 from the given modbus data without performing bounds checks .
data
&[u8]
data
&[u8]