3
3
//!
4
4
//! ## Example
5
5
//!
6
- //! ```ignore
6
+ //! ```no_run
7
7
//! extern crate bytesize;
8
8
//!
9
9
//! use bytesize::ByteSize;
14
14
//!
15
15
//! let plus = x + y;
16
16
//! print!("{} bytes", plus.as_u64());
17
- //!
18
- //! let minus = ByteSize::tb(100) - ByteSize::gb(4);
19
- //! print!("{} bytes", minus.as_u64());
20
17
//! }
21
18
//! ```
22
19
//!
23
20
//! It also provides its human readable string as follows:
24
21
//!
25
- //! ```ignore=
26
- //! assert_eq!("482 GiB".to_string(), ByteSize::gb(518).to_string(true));
27
- //! assert_eq!("518 GB".to_string(), ByteSize::gb(518).to_string(false));
22
+ //! ```no_run
23
+ //! # use bytesize::ByteSize;
24
+ //! assert_eq!("482 GiB".to_string(), ByteSize::gb(518).to_string());
25
+ //! assert_eq!("518 GB".to_string(), ByteSize::gb(518).to_string());
28
26
//! ```
29
27
30
28
mod parse;
@@ -208,7 +206,7 @@ pub fn to_string(bytes: u64, si_prefix: bool) -> String {
208
206
}
209
207
210
208
impl Display for ByteSize {
211
- fn fmt ( & self , f : & mut Formatter ) ->fmt:: Result {
209
+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
212
210
f. pad ( & to_string ( self . 0 , false ) )
213
211
}
214
212
}
@@ -261,7 +259,9 @@ impl AddAssign<ByteSize> for ByteSize {
261
259
}
262
260
263
261
impl < T > Add < T > for ByteSize
264
- where T : Into < u64 > {
262
+ where
263
+ T : Into < u64 > ,
264
+ {
265
265
type Output = ByteSize ;
266
266
#[ inline( always) ]
267
267
fn add ( self , rhs : T ) -> ByteSize {
@@ -270,15 +270,19 @@ impl<T> Add<T> for ByteSize
270
270
}
271
271
272
272
impl < T > AddAssign < T > for ByteSize
273
- where T : Into < u64 > {
273
+ where
274
+ T : Into < u64 > ,
275
+ {
274
276
#[ inline( always) ]
275
277
fn add_assign ( & mut self , rhs : T ) {
276
278
self . 0 += rhs. into ( ) as u64 ;
277
279
}
278
280
}
279
281
280
282
impl < T > Mul < T > for ByteSize
281
- where T : Into < u64 > {
283
+ where
284
+ T : Into < u64 > ,
285
+ {
282
286
type Output = ByteSize ;
283
287
#[ inline( always) ]
284
288
fn mul ( self , rhs : T ) -> ByteSize {
@@ -287,7 +291,9 @@ impl<T> Mul<T> for ByteSize
287
291
}
288
292
289
293
impl < T > MulAssign < T > for ByteSize
290
- where T : Into < u64 > {
294
+ where
295
+ T : Into < u64 > ,
296
+ {
291
297
#[ inline( always) ]
292
298
fn mul_assign ( & mut self , rhs : T ) {
293
299
self . 0 *= rhs. into ( ) as u64 ;
0 commit comments