Struct byte_unit::AdjustedByte
source · pub struct AdjustedByte(_);Expand description
Generated from the get_appropriate_unit and get_adjusted_unit methods of a Byte object.
Implementations
sourceimpl AdjustedByte
impl AdjustedByte
sourcepub fn format(&self, fractional_digits: usize) -> String
pub fn format(&self, fractional_digits: usize) -> String
Format the AdjustedByte object to string.
Examples
extern crate byte_unit;
use byte_unit::{Byte, ByteUnit};
let byte = Byte::from_unit(1555f64, ByteUnit::KB).unwrap();
let result = byte.get_appropriate_unit(false).format(3);
assert_eq!(result, "1.555 MB");pub fn get_value(&self) -> f64
pub fn get_unit(&self) -> &ByteUnit
Trait Implementations
sourceimpl Debug for AdjustedByte
impl Debug for AdjustedByte
sourceimpl PartialEq<AdjustedByte> for AdjustedByte
impl PartialEq<AdjustedByte> for AdjustedByte
sourcefn eq(&self, other: &AdjustedByte) -> bool
fn eq(&self, other: &AdjustedByte) -> bool
Deal with the logical numeric equivalent.
Examples
extern crate byte_unit;
use byte_unit::{Byte, ByteUnit};
let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
let byte2 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
assert_eq!(byte1.get_appropriate_unit(false), byte2.get_appropriate_unit(true));extern crate byte_unit;
use byte_unit::{Byte, ByteUnit};
let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
let byte2 = Byte::from_unit(1f64, ByteUnit::MiB).unwrap();
assert_eq!(byte1.get_appropriate_unit(true), byte2.get_appropriate_unit(false));sourceimpl ToString for AdjustedByte
impl ToString for AdjustedByte
sourcefn to_string(&self) -> String
fn to_string(&self) -> String
Format the AdjustedByte object to string. The number of fractional digits is 2.
Examples
extern crate byte_unit;
use byte_unit::{Byte, ByteUnit};
let byte = Byte::from_unit(1500f64, ByteUnit::KB).unwrap();
let result = byte.get_appropriate_unit(false).to_string();
assert_eq!(result, "1.50 MB");Auto Trait Implementations
impl RefUnwindSafe for AdjustedByte
impl Send for AdjustedByte
impl Sync for AdjustedByte
impl Unpin for AdjustedByte
impl UnwindSafe for AdjustedByte
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more