This lib aims at converting human-readable strings to specific types.
It's mainly used in parsing config files.
Add this lib as a dependency
[dependencies]
humanize-rs = "0.1"
Add the crate reference
extern crate humanize_rs;
``` use humanize_rs::bytes::{Bytes, Unit};
let gigabytes1 = Bytes::new(1, Unit::GiByte);
let gigabytes2 = "1 GiB".parse::
``` use humanize_rs::duration::parse; use std::time::Duration;
asserteq!(parse("1h 30m 71s"), Ok(Duration::fromsecs(60 * 90 + 71))); ```
``` use humanize_rs::time::{Time, TimeZone};
asserteq!( "2018-09-21T16:56:44.234867232+08:00".parse::timetuple( 2018, 9, 21, 16, 56, 44, 234867232, TimeZone::new(8).unwrap(), ).unwrap()) ); ```
Any PRs or issues are welcomed.