1 unstable release

Uses old Rust 2015

0.1.0 Nov 12, 2016

#27 in #human-friendly

Download history 15/week @ 2023-11-27 2/week @ 2023-12-04 8/week @ 2023-12-11 12/week @ 2023-12-18 16/week @ 2024-01-08 7/week @ 2024-01-15 3/week @ 2024-01-22 13/week @ 2024-02-12 123/week @ 2024-02-19 65/week @ 2024-02-26 24/week @ 2024-03-04 27/week @ 2024-03-11

242 downloads per month
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

~290KB