Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. CI Status codecov.io MIT License

GitHub | crates.io | Documentation | Issues

strtoint provides a function of the same name for parsing integer literals from strings, with support for the base prefixes 0x, 0o, and 0b for hexadecimal, octal, and binary literals, respectively.

This crate supports parsing into all primitive integer types built into Rust, along with their "NonZero" equivalents.

If the std feature (enabled by default) is disabled, this crate will be built in no-std mode. The only difference is that StrToIntError only implements the std::error::Error trait under std.

Installation

strtoint requires version 1.56 of Rust or higher. To use the strtoint library in your Cargo project, add the following to your Cargo.toml:

toml [dependencies] strtoint = "0.1.0-alpha"

Examples

```rust use core::num::NonZeroUsize; use strtoint::strtoint;

asserteq!(strtoint::("123").unwrap(), 123); asserteq!(strtoint::("0xabcdFFFF").unwrap(), 2882404351); asserteq!(strtoint::("0o644").unwrap(), 420); asserteq!(strtoint::("-0b00101010").unwrap(), -42); assert!(strtoint::("42.0").iserr());

asserteq!( strtoint::("123456").unwrap(), NonZeroUsize::new(123456).unwrap() ); assert!(strtoint::("0").is_err()); ```