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§

source

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§

source

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());
source

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());

Implementations on Foreign Types§

source§

impl HumanCount for u128

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for i32

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for i128

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for u64

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for u32

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for i64

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for usize

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for isize

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for i16

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for u8

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for u16

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for i8

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for f64

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

source§

impl HumanCount for f32

source§

fn human_count<'a>(self, unit: impl Into<Cow<'a, str>>) -> HumanCountData<'a>

Implementors§