pub fn btou_saturating<I>(bytes: &[u8]) -> Result<I, ParseIntegerError>Expand description
Converts a byte slice to the closest possible integer. Signs are not allowed.
§Errors
Returns ParseIntegerError for any of the following conditions:
bytesis empty- not all characters of
bytesare0-9
§Panics
Panics in the pathological case that there is no representation of 10
in I.
§Examples
assert_eq!(Ok(65535), btou_saturating::<u16>(b"65535"));
assert_eq!(Ok(65535), btou_saturating::<u16>(b"65536")); // u16 saturated
assert_eq!(Ok(65535), btou_saturating::<u16>(b"65537")); // u16 saturated