Trait human_repr::HumanCount
source · pub trait HumanCount: Sealed + Sized {
// Required method
fn human_count<'a>(
self,
unit: impl Into<Cow<'a, str>>
) -> HumanCountData<'a>;
// Provided methods
fn human_count_bare(self) -> HumanCountData<'static> { ... }
fn human_count_bytes(self) -> HumanCountData<'static> { ... }
}
Expand description
Human Count trait, supporting all Rust primitive number types.
Required Methods§
sourcefn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>
fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>
Generate beautiful human-readable counts supporting automatic prefixes and custom units.
use human_repr::HumanCount;
assert_eq!("4.2Mcoins", 4221432u32.human_count("coins"));
Provided Methods§
sourcefn human_count_bare(self) -> HumanCountData<'static>
fn human_count_bare(self) -> HumanCountData<'static>
Generate beautiful human-readable counts supporting automatic prefixes.
use human_repr::HumanCount;
assert_eq!("4.2M", 4221432u32.human_count_bare());
sourcefn human_count_bytes(self) -> HumanCountData<'static>
fn human_count_bytes(self) -> HumanCountData<'static>
Generate beautiful human-readable counts supporting automatic prefixes and Bytes B
as the unit.
use human_repr::HumanCount;
assert_eq!("4.2MB", 4221432u32.human_count_bytes());