Skip to content

It would be great if we were to allow creating ByteSize constants #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,57 +110,57 @@ pub struct ByteSize(pub u64);

impl ByteSize {
#[inline(always)]
pub fn b(size: u64) -> ByteSize {
pub const fn b(size: u64) -> ByteSize {
ByteSize(size)
}

#[inline(always)]
pub fn kb(size: u64) -> ByteSize {
pub const fn kb(size: u64) -> ByteSize {
ByteSize(size * KB)
}

#[inline(always)]
pub fn kib(size: u64) -> ByteSize {
pub const fn kib(size: u64) -> ByteSize {
ByteSize(size * KIB)
}

#[inline(always)]
pub fn mb(size: u64) -> ByteSize {
pub const fn mb(size: u64) -> ByteSize {
ByteSize(size * MB)
}

#[inline(always)]
pub fn mib(size: u64) -> ByteSize {
pub const fn mib(size: u64) -> ByteSize {
ByteSize(size * MIB)
}

#[inline(always)]
pub fn gb(size: u64) -> ByteSize {
pub const fn gb(size: u64) -> ByteSize {
ByteSize(size * GB)
}

#[inline(always)]
pub fn gib(size: u64) -> ByteSize {
pub const fn gib(size: u64) -> ByteSize {
ByteSize(size * GIB)
}

#[inline(always)]
pub fn tb(size: u64) -> ByteSize {
pub const fn tb(size: u64) -> ByteSize {
ByteSize(size * TB)
}

#[inline(always)]
pub fn tib(size: u64) -> ByteSize {
pub const fn tib(size: u64) -> ByteSize {
ByteSize(size * TIB)
}

#[inline(always)]
pub fn pb(size: u64) -> ByteSize {
pub const fn pb(size: u64) -> ByteSize {
ByteSize(size * PB)
}

#[inline(always)]
pub fn pib(size: u64) -> ByteSize {
pub const fn pib(size: u64) -> ByteSize {
ByteSize(size * PIB)
}

Expand Down