pub fn to_unsigned<I: MinNumTraits>(
bytes: &[u8],
) -> Result<I, ParseIntegerError>Expand description
Converts a byte slice to an integer. Signs are not allowed.
§Errors
Returns ParseIntegerError for any of the following conditions:
bytesis empty- not all characters of
bytesare0-9 - the number overflows
I
§Panics
Panics in the pathological case that there is no representation of 10
in I.
§Examples
assert_eq!(Ok(12345), to_unsigned(b"12345"));
assert!(to_unsigned::<u8>(b"+1").is_err()); // only btoi allows signs
assert!(to_unsigned::<u8>(b"256").is_err()); // overflow