@@ -33,28 +33,26 @@ mod serde;
3333use std:: fmt:: { self , Debug , Display , Formatter } ;
3434use std:: ops:: { Add , AddAssign , Mul , MulAssign , Sub , SubAssign } ;
3535
36- /// byte size for 1 byte
37- pub const B : u64 = 1 ;
38- /// bytes size for 1 kilobyte
36+ /// Number of bytes in 1 kilobyte.
3937pub const KB : u64 = 1_000 ;
40- /// bytes size for 1 megabyte
38+ /// Number of bytes in 1 megabyte.
4139pub const MB : u64 = 1_000_000 ;
42- /// bytes size for 1 gigabyte
40+ /// Number of bytes in 1 gigabyte.
4341pub const GB : u64 = 1_000_000_000 ;
44- /// bytes size for 1 terabyte
42+ /// Number of bytes in 1 terabyte.
4543pub const TB : u64 = 1_000_000_000_000 ;
46- /// bytes size for 1 petabyte
44+ /// Number of bytes in 1 petabyte.
4745pub const PB : u64 = 1_000_000_000_000_000 ;
4846
49- /// bytes size for 1 kibibyte
47+ /// Number of bytes in 1 kibibyte.
5048pub const KIB : u64 = 1_024 ;
51- /// bytes size for 1 mebibyte
49+ /// Number of bytes in 1 mebibyte.
5250pub const MIB : u64 = 1_048_576 ;
53- /// bytes size for 1 gibibyte
51+ /// Number of bytes in 1 gibibyte.
5452pub const GIB : u64 = 1_073_741_824 ;
55- /// bytes size for 1 tebibyte
53+ /// Number of bytes in 1 tebibyte.
5654pub const TIB : u64 = 1_099_511_627_776 ;
57- /// bytes size for 1 pebibyte
55+ /// Number of bytes in 1 pebibyte.
5856pub const PIB : u64 = 1_125_899_906_842_624 ;
5957
6058/// IEC (binary) units.
@@ -416,21 +414,12 @@ mod tests {
416414 let mut x = ByteSize :: mb ( 1 ) ;
417415
418416 assert_eq ! ( ( x + MB as u64 ) . as_u64( ) , 2_000_000 ) ;
419-
420417 assert_eq ! ( ( x + MB as u32 ) . as_u64( ) , 2_000_000 ) ;
421-
422418 assert_eq ! ( ( x + KB as u16 ) . as_u64( ) , 1_001_000 ) ;
423-
424- assert_eq ! ( ( x + B as u8 ) . as_u64( ) , 1_000_001 ) ;
425-
426419 assert_eq ! ( ( x - MB as u64 ) . as_u64( ) , 0 ) ;
427-
428420 assert_eq ! ( ( x - MB as u32 ) . as_u64( ) , 0 ) ;
429-
430421 assert_eq ! ( ( x - KB as u32 ) . as_u64( ) , 999_000 ) ;
431422
432- assert_eq ! ( ( x - B as u32 ) . as_u64( ) , 999_999 ) ;
433-
434423 x += MB as u64 ;
435424 x += MB as u32 ;
436425 x += 10u16 ;
0 commit comments