1 unstable release

Uses old Rust 2015

0.1.0 Nov 12, 2016

#32 in #human-friendly


Used in 4 crates (via quire)

MIT/Apache

9KB
162 lines

Human Num

Status:beta
Documentation:http://tailhook.github.io/humannum/

Human-friendly numeric parser.

Supported features:

  • Supports for underscore in numbers 1_000 → 1000
  • k, M, G -- decimal suffixes 25M → 25000000
  • ki, Mi, Gi -- binary suffixes 8Ki → 8192
  • 0x, 0o, 0b -- prefixes numeral systems 0xFF → 255, 0o40 → 32, 0b11 → 3
  • Wrapper type that implements FromStr

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Human-friendly number parser

Currently this only currently implements parsing of integers.

The format of values accepted is described in docstring of parse_integer.

Example (Functional)

use humannum::parse_integer;
let x: u64 = parse_integer("1_320 k").unwrap();
assert_eq!(x, 1320000);

Example (wrapper)

use humannum::Int;
let x: Int<u32> = "0o1777".parse().unwrap();
assert_eq!(*x, 0o1777)

Dependencies

~285KB