pub struct ByteSize(pub u64);Expand description
Helper struct that wraps a byte count and improves its std::fmt::Debug formatting.
Formats the value as a human-readable size, automatically selecting the most appropriate
unit (B, KiB, MiB, GiB, TiB). Trailing fractional zeros are omitted, and exact multiples
of a unit are printed without a decimal point entirely.
§Examples
assert_eq!(format!("{:?}", ByteSize(484)), "484B");
assert_eq!(format!("{:?}", ByteSize(1536)), "1.5KiB");
assert_eq!(format!("{:?}", ByteSize(2147483648)), "2GiB");
assert_eq!(format!("{:?}", ByteSize(2684354560)), "2.5GiB");Tuple Fields§
§0: u64Trait Implementations§
Auto Trait Implementations§
impl Freeze for ByteSize
impl RefUnwindSafe for ByteSize
impl Send for ByteSize
impl Sync for ByteSize
impl Unpin for ByteSize
impl UnsafeUnpin for ByteSize
impl UnwindSafe for ByteSize
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more