# Readable
[](https://github.com/hinto-janai/readable/actions/workflows/windows.yml) [](https://github.com/hinto-janai/readable/actions/workflows/macos.yml) [](https://github.com/hinto-janai/readable/actions/workflows/linux.yml) [](https://crates.io/crates/readable) [](https://docs.rs/readable)
Human **readable** data formatting.
This crate turns various data into human-readable strings.
## Feature flags
| Flag | Purpose |
|------------------|---------|
| `serde` | Enable [`serde`](https://docs.rs/serde) on all types
| `ignore_nan_inf` | Disable checking `f64`'s for `f64::NAN`, `f64::INFINITY`, and `f64::NEG_INFINITY`
## Unsigned integers:
```rust
let a = readable::Unsigned::from(1000_u64);
assert!(a == 1000_u64);
assert!(a == "1,000");
```
## Signed integers:
```rust
let a = readable::Int::from(-1000);
assert!(a == -1000);
assert!(a == "-1,000");
```
## Floats:
```rust
let a = readable::Float::from(1000.123);
assert!(a == 1000.123);
assert!(a == "1,000.123");
```
## Percents:
```rust
let a = readable::Percent::from(1000.123);
assert!(a == 1000.123);
assert!(a == "1,000.12%");
```
## Runtime:
```rust
let a = readable::Runtime::from(11111.1);
assert!(a == 11111.1);
assert!(a == "3:05:11");
```
## Time:
```rust
let a = readable::Time::from(86399_u64);
assert!(a == 86399_u64);
assert!(a == "23 hours, 59 minutes, 59 seconds");
```
## Comparison
All types implement `Display`, `PartialEq`, `PartialEq<&str>` and `PartialEq` for their inner number primitive.
Example 1:
```rust
let a = std::time::Duration::from_secs(86399);
let b = readable::Time::from(a);
assert!(b == "23 hours, 59 minutes, 59 seconds");
```
This is comparing `b`'s inner `String`.
Example 2:
```rust
let a = readable::Int::from(-1000);
assert!(a == -1000);
```
This is comparing `a`'s inner `i64`.
Example 3:
```rust
let a = readable::Unsigned::from(1000);
let b = readable::Unsigned::from(1000);
assert!(a == b);
```
This compares both the `u64` AND `String` inside `a` and `b`.