33//!
44//! ## Example
55//!
6- //! ```ignore
6+ //! ```no_run
77//! extern crate bytesize;
88//!
99//! use bytesize::ByteSize;
1414//!
1515//! let plus = x + y;
1616//! print!("{} bytes", plus.as_u64());
17- //!
18- //! let minus = ByteSize::tb(100) - ByteSize::gb(4);
19- //! print!("{} bytes", minus.as_u64());
2017//! }
2118//! ```
2219//!
2320//! It also provides its human readable string as follows:
2421//!
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());
2826//! ```
2927
3028mod parse;
@@ -208,7 +206,7 @@ pub fn to_string(bytes: u64, si_prefix: bool) -> String {
208206}
209207
210208impl Display for ByteSize {
211- fn fmt ( & self , f : & mut Formatter ) ->fmt:: Result {
209+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
212210 f. pad ( & to_string ( self . 0 , false ) )
213211 }
214212}
@@ -261,7 +259,9 @@ impl AddAssign<ByteSize> for ByteSize {
261259}
262260
263261impl < T > Add < T > for ByteSize
264- where T : Into < u64 > {
262+ where
263+ T : Into < u64 > ,
264+ {
265265 type Output = ByteSize ;
266266 #[ inline( always) ]
267267 fn add ( self , rhs : T ) -> ByteSize {
@@ -270,15 +270,19 @@ impl<T> Add<T> for ByteSize
270270}
271271
272272impl < T > AddAssign < T > for ByteSize
273- where T : Into < u64 > {
273+ where
274+ T : Into < u64 > ,
275+ {
274276 #[ inline( always) ]
275277 fn add_assign ( & mut self , rhs : T ) {
276278 self . 0 += rhs. into ( ) as u64 ;
277279 }
278280}
279281
280282impl < T > Mul < T > for ByteSize
281- where T : Into < u64 > {
283+ where
284+ T : Into < u64 > ,
285+ {
282286 type Output = ByteSize ;
283287 #[ inline( always) ]
284288 fn mul ( self , rhs : T ) -> ByteSize {
@@ -287,7 +291,9 @@ impl<T> Mul<T> for ByteSize
287291}
288292
289293impl < T > MulAssign < T > for ByteSize
290- where T : Into < u64 > {
294+ where
295+ T : Into < u64 > ,
296+ {
291297 #[ inline( always) ]
292298 fn mul_assign ( & mut self , rhs : T ) {
293299 self . 0 *= rhs. into ( ) as u64 ;
0 commit comments