Crate scolapasta_int_parse

source ·
Expand description

Parse a given byte string and optional radix into an i64.

parse wraps i64::from_str_radix by normalizing the input byte string:

  • Assert the byte string is ASCII and does not contain NUL bytes.
  • Parse the radix to ensure it is in range and valid for the given input byte string.
  • Trim leading whitespace.
  • Accept a single, optional + or - sign byte.
  • Parse a literal radix out of the string from one of 0b, 0B, 0o, 0O, 0d, 0D, 0x, or 0X. If the given radix is Some(_), the radix must match the embedded radix literal. A 0 prefix of arbitrary length is interpreted as an octal literal.
  • Remove (“squeeze”) leading zeros.
  • Collect ASCII alphanumeric bytes and filter out underscores.

The functions and types in this crate can be used to implement Kernel#Integer in Ruby.

Structs§

  • Error that indicates the byte string input to parse was invalid.
  • Error that indicates the radix input to parse was invalid.
  • A checked container for the radix to use when converting a string to an integer.

Enums§

Functions§