Readable
Human readable strings.
This library:
- Transforms various data types into human-readable strings
- Parses raw string data into human-readable versions
- Provides various string types and utilities
Most of the strings are implemented as fixed sized stack allocated arrays that are Copy
-able.
In general, readable
types are often used where you need to quickly format some data into a more human-friendly string, display it, then throw it away (although most readable
types are perfectly fine to permanently store).
Creation of readable
types is relatively performant.
Examples
Unsigned
use *;
assert_eq!;
Int
use *;
assert_eq!;
Float
use *;
assert_eq!;
Percent
use *;
assert_eq!;
Runtime
use *;
assert_eq!;
assert_eq!;
assert_eq!;
Uptime
use *;
assert_eq!;
assert_eq!;
assert_eq!;
Date
use *;
assert_eq!;
assert_eq!;
assert_eq!;
Time
use *;
assert_eq!;
assert_eq!;
Byte
use *;
assert_eq!;
Comparison
All number types implement PartialEq
against str
and their internal numbers.
This is comparing b
's inner String
:
use *;
let a = from_secs;
let b = from;
assert_eq!;
This is comparing a
's inner i64
:
use *;
let a = from;
assert_eq!;
This compares both the u64
AND String
inside a
and b
:
use *;
let a = from;
let b = from;
assert_eq!;
Arithmetic
All number types implement the common arithmetic operators +
, -
, /
, *
, %
, outputting a new Self
.
+
Addition
use *;
let f1 = from;
let f2 = from;
assert_eq!;
-
Subtraction
use *;
let p50 = from;
let p25 = from;
assert_eq!;
/
Division
use *;
let u100 = from;
let u10 = from;
assert_eq!;
*
Multiplication
use *;
let u10 = from;
assert_eq!;
%
Modulo
use *;
let u10 = from;
assert_eq!;
Feature Flags
Flag | Purpose |
---|---|
serde |
Enables serde on most types |
bincode |
Enables bincode 2.0.0-rc.3 's Encode/Decode on most types |
Re-exports
Types are separated per module depending on what type of data they take as input, and what type of data they output.
use ;
All major types are exported to the root, so they can be imported without specifying the full path:
// shorter
use HeadTail;
// longer
// use readable::str::HeadTail;