Skip to content

Commit

Permalink
chore: remove to_string_as method
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Feb 12, 2025
1 parent 81d19ce commit 5fc167a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
- Implement `SubAssign<ByteSize>` for `ByteSize`.
- Implement `SubAssign<impl Into<u64>>` for `ByteSize`.
- Reject parsing non-unit characters after whitespace.
- Remove `ByteSize::to_string_as()` method.
- Remove top-level `to_string()` method.
12 changes: 1 addition & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
//! ```
//! use bytesize::ByteSize;
//!
//! assert_eq!("482.4 GiB", ByteSize::gb(518).to_string_as(false));
//! assert_eq!("518.0 GB", ByteSize::gb(518).to_string_as(true));
//! assert_eq!("482.4 GiB", ByteSize::gb(518).to_string());
//! ```
//!
//! Arithmetic operations are supported.
Expand Down Expand Up @@ -199,15 +198,6 @@ impl ByteSize {
pub const fn as_u64(&self) -> u64 {
self.0
}

#[inline(always)]
pub fn to_string_as(&self, si_unit: bool) -> String {
to_string(self.0, si_unit)
}
}

pub fn to_string(bytes: u64, si_unit: bool) -> String {
to_string_format(bytes, if si_unit { Format::SI } else { Format::IEC })
}

pub fn to_string_format(bytes: u64, format: Format) -> String {
Expand Down

0 comments on commit 5fc167a

Please sign in to comment.