Skip to content

Commit

Permalink
Update consts documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mqudsi committed Apr 25, 2024
1 parent 2f1d6bc commit 3a6926f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ size = "0.4"
and in your code:

```rust
use size::consts;
use size::{Base, Size};
// You can use/import consts representing base2/base10 sizes individually
// as (e.g.) size::KiB, or import all with `use size::consts::*`

fn main() {
// Create strongly-typed sizes:
let byte_count = Size::from_kilobytes(42);
assert_eq!(42_000, byte_count.bytes());

// Use predefined constants for the various units
let byte_count = 42 * consts::KiB;
let byte_count = 42 * size::KiB;
assert_eq!(43_008, byte_count);

// `Size` can take any numeric type you throw at it
Expand Down

0 comments on commit 3a6926f

Please sign in to comment.