Struct frequency_unit::Frequency
source · pub struct Frequency { /* private fields */ }Implementations§
Trait Implementations§
source§impl AddAssign for Frequency
impl AddAssign for Frequency
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moresource§impl Display for Frequency
impl Display for Frequency
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter.
§Examples
use byte_unit::{Byte, Unit};
let byte = Byte::from_u64_with_unit(1555, Unit::KB).unwrap();
assert_eq!("1555000", byte.to_string());use byte_unit::{Byte, UnitType};
let byte_based_2 = Byte::from_u64(10240);
let byte_based_10 = Byte::from_u64(10000);
assert_eq!("10240", format!("{byte_based_2}"));
assert_eq!("10000", format!("{byte_based_10}"));
// with an exact unit
assert_eq!("10 KiB", format!("{byte_based_2:#}"));
assert_eq!("10 KB", format!("{byte_based_10:#}"));
// with an exact unit, no spaces between the value and the unit
assert_eq!("10KiB", format!("{byte_based_2:-#}"));
assert_eq!("10KB", format!("{byte_based_10:-#}"));
// with a width, left alignment
assert_eq!("10 KiB", format!("{byte_based_2:#10}"));
assert_eq!("10 KB", format!("{byte_based_10:#10}"));
// with a width, right alignment
assert_eq!(" 10 KiB", format!("{byte_based_2:>#10}"));
assert_eq!(" 10 KB", format!("{byte_based_10:>#10}"));
// with a width, right alignment, more spaces between the value and the unit
assert_eq!(" 10 KiB", format!("{byte_based_2:>+#10}"));
assert_eq!(" 10 KB", format!("{byte_based_10:>+#10}"));use byte_unit::{Byte, UnitType};
let byte = Byte::from_u64(3211776);
assert_eq!("3211776", format!("{byte}"));
// with a unit, still precisely
assert_eq!("3136.5 KiB", format!("{byte:#}"));
// with a unit and a larger precision (default is 3), still precisely
assert_eq!("3.211776 MB", format!("{byte:#.6}"));
// with a unit and a smaller precision (default is 3), still precisely
assert_eq!("3211776 B", format!("{byte:#.0}"));source§impl PartialEq for Frequency
impl PartialEq for Frequency
source§impl PartialOrd for Frequency
impl PartialOrd for Frequency
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl SubAssign for Frequency
impl SubAssign for Frequency
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Frequency
Auto Trait Implementations§
impl Freeze for Frequency
impl RefUnwindSafe for Frequency
impl Send for Frequency
impl Sync for Frequency
impl Unpin for Frequency
impl UnwindSafe for Frequency
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)