29
29
30
30
mod parse;
31
31
32
+ #[ cfg( feature = "arbitrary" ) ]
33
+ extern crate arbitrary;
32
34
#[ cfg( feature = "serde" ) ]
33
35
extern crate serde;
34
36
#[ cfg( feature = "serde" ) ]
@@ -110,6 +112,7 @@ pub fn pib<V: Into<u64>>(size: V) -> u64 {
110
112
111
113
/// Byte size representation
112
114
#[ derive( Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash , Default ) ]
115
+ #[ cfg_attr( feature = "arbitrary" , derive( arbitrary:: Arbitrary ) ) ]
113
116
pub struct ByteSize ( pub u64 ) ;
114
117
115
118
impl ByteSize {
@@ -208,7 +211,7 @@ pub fn to_string(bytes: u64, si_prefix: bool) -> String {
208
211
}
209
212
210
213
impl Display for ByteSize {
211
- fn fmt ( & self , f : & mut Formatter ) ->fmt:: Result {
214
+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
212
215
f. pad ( & to_string ( self . 0 , false ) )
213
216
}
214
217
}
@@ -261,7 +264,9 @@ impl AddAssign<ByteSize> for ByteSize {
261
264
}
262
265
263
266
impl < T > Add < T > for ByteSize
264
- where T : Into < u64 > {
267
+ where
268
+ T : Into < u64 > ,
269
+ {
265
270
type Output = ByteSize ;
266
271
#[ inline( always) ]
267
272
fn add ( self , rhs : T ) -> ByteSize {
@@ -270,15 +275,19 @@ impl<T> Add<T> for ByteSize
270
275
}
271
276
272
277
impl < T > AddAssign < T > for ByteSize
273
- where T : Into < u64 > {
278
+ where
279
+ T : Into < u64 > ,
280
+ {
274
281
#[ inline( always) ]
275
282
fn add_assign ( & mut self , rhs : T ) {
276
283
self . 0 += rhs. into ( ) as u64 ;
277
284
}
278
285
}
279
286
280
287
impl < T > Mul < T > for ByteSize
281
- where T : Into < u64 > {
288
+ where
289
+ T : Into < u64 > ,
290
+ {
282
291
type Output = ByteSize ;
283
292
#[ inline( always) ]
284
293
fn mul ( self , rhs : T ) -> ByteSize {
@@ -287,7 +296,9 @@ impl<T> Mul<T> for ByteSize
287
296
}
288
297
289
298
impl < T > MulAssign < T > for ByteSize
290
- where T : Into < u64 > {
299
+ where
300
+ T : Into < u64 > ,
301
+ {
291
302
#[ inline( always) ]
292
303
fn mul_assign ( & mut self , rhs : T ) {
293
304
self . 0 *= rhs. into ( ) as u64 ;
0 commit comments