2 unstable releases

0.2.0 Dec 30, 2024
0.1.0 Jun 10, 2021

#167 in Date and time

Download history 17/week @ 2024-09-25 7/week @ 2024-10-02 2/week @ 2024-10-09 1/week @ 2024-10-30 2/week @ 2024-11-06 1/week @ 2024-11-13 2/week @ 2024-11-20 3/week @ 2024-11-27 8/week @ 2024-12-04 24/week @ 2024-12-11 6/week @ 2024-12-18 101/week @ 2024-12-25 53/week @ 2025-01-01 8/week @ 2025-01-08

170 downloads per month
Used in 2 crates

MIT license

24KB
590 lines

friendly is a human-readable display library.

This module provides a convenient, uniform way to display various types of quantities in approximate, human-readable format. For example:

# use friendly::bytes;
let kb = format!("{}", bytes(13200));
assert_eq!(kb.as_str(), "12.89 KiB")

The various functions provide quick ways to wrap values and types in the appropriate objects to facilitate their display. Types such as [Quantity] then provide methods to further customize this presentation.

Right now this crate supports a few useful types, but has much more to add. Contributions (via pull requests) are most welcome! Please make sure you include tests, though.

Features

This crate supports some features:

  • chrono — enables support for types from the Chrono crate (currently just chrono::Duration)

lib.rs:

Human-friendly display library.

This module provides a convenient, uniform way to display various types of quantities in approximate, human-readable format. For example:

let kb = format!("{}", bytes(13200));
assert_eq!(kb.as_str(), "12.89 KiB")

The various functions provide quick ways to wrap values and types in the appropriate objects to facilitate their display. Types such as [Quantity] then provide methods to further customize this presentation.

Features

This crate supports some features:

  • chrono — enables support for types from the Chrono crate (currently just chrono::Duration)

Dependencies

~93–410KB