fn to_milliunits(bytes: &[u8]) -> Option<u32> {
    match bytes[0] as char {
        '-' => None, // device is off
        _ => String::from_utf8_lossy(bytes).trim_left()
                                           .parse::<f32>()
                                           .ok()
                                           .map(|val| (val * 1000.0) as u32)
    }
}
/// Values are only accurate to 3 decimal places, so we don't lose any precision
Values are only accurate to 3 decimal places, so we don't lose any precision
Values are only accurate to 3 decimal places so we don ' t lose any precision
fn to_milliunits(bytes: &[u8]) -> Option<u32> {
    match bytes[0] as char {
        '-' => None, // device is off
        _ => String::from_utf8_lossy(bytes).trim_left()
                                           .parse::<f32>()
                                           .ok()
                                           .map(|val| (val * 1000.0) as u32)
    }
}
fn to_milliunits ( bytes : & [ u8 ] ) -> Option < u32 > { match bytes [ 0 ] as char { '-' => None , // device is off _ => String :: from_utf8_lossy ( bytes ) . trim_left ( ) . parse :: < f32 > ( ) . ok ( ) . map ( | val | ( val * 1000.0 ) as u32 ) } }
Values are only accurate to 3 decimal places, so we don't lose any precision
Values are only accurate to 3 decimal places so we don ' t lose any precision
bytes
&[u8]
bytes
&[u8]