Fix to a minor fumble over SI prefixes, some internal refactoring, and minor API additions.

- Added new function max() to byteunit type.
- New public constant 'simplebyteunit::MAX' defining the maximum supported power.
- Output module to house arithmetic and prefix functions for output values.
- For the sake of SI compliance, kilobytes are now prefixed as 'kB'.
This commit is contained in:
Xavier Moffett 2023-09-28 23:08:41 -04:00
parent e4204d588e
commit 7d182d860b
5 changed files with 87 additions and 67 deletions

View file

@ -19,7 +19,7 @@ Add 'simplebyteunit' to your 'Cargo.toml':
```toml
[dependencies]
simplebyteunit = "0.1.0"
simplebyteunit = "0.2.0"
```
## Example
@ -39,7 +39,7 @@ println!("{byteunit_var}");
Output:
```shell
500 KB
500 kB
````
## Parsing strings into ByteUnits
@ -49,7 +49,7 @@ And then you can parse formatted strings back into a ByteUnit
```rust
use simplebyteunit::simplebyteunit::*;
let byteunit_var: ByteUnit<i64> = "500 KB".into();
let byteunit_var: ByteUnit<i64> = "500 kB".into();
println!("{byteunit_var}");
@ -58,7 +58,7 @@ println!("{byteunit_var}");
Output:
```shell
500 KB
500 kB
````
## Simple arithmetic operations
@ -102,7 +102,7 @@ Output:
true
````
Or operations are supported directly on this type:
Or operations are also supported on this type:
```rust
use simplebyteunit::simplebyteunit::*;
@ -125,4 +125,5 @@ true
pub mod simplebyteunit;
mod input;
mod output;
mod test;