pub struct AdjustedByte(_);
Generated from the get_appropriate_unit
and get_adjusted_unit
methods of a Byte
object.
Format the AdjustedByte
object to string.
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");
Formats the value using the given formatter. Read more
Deal with the logical numeric equivalent.
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));
This method tests for !=
.
Format the AdjustedByte
object to string. The number of fractional digits is 2.
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");