Skip to content

Commit f16ba51

Browse files
committed
activates ignored crate documentation tests
1 parent d3be6c8 commit f16ba51

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/lib.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
//! ByteSize is a utility that easily makes bytes size representation and helps
22
//! its arithmetic operations.
33
//!
4-
//! ## Example
4+
//! ## Human Readable Representation
55
//!
6-
//! ```ignore
6+
//! ByteSize provides a human readable string conversion as follows:
7+
//!
8+
//! ```
79
//! extern crate bytesize;
810
//!
9-
//! use bytesize::ByteSize;
11+
//! use bytesize::{ByteSize, IEC, SI};
1012
//!
11-
//! fn byte_arithmetic_operator() {
12-
//! let x = ByteSize::mb(1);
13-
//! let y = ByteSize::kb(100);
13+
//! assert_eq!("482.4 GiB".to_string(), ByteSize::gb(518).humanize(IEC));
14+
//! assert_eq!("518.0 GB".to_string(), ByteSize::gb(518).humanize(SI));
15+
//! ```
1416
//!
15-
//! let plus = x + y;
16-
//! print!("{} bytes", plus.as_u64());
17+
//! ## Arithmetic
1718
//!
18-
//! let minus = ByteSize::tb(100) - ByteSize::gb(4);
19-
//! print!("{} bytes", minus.as_u64());
20-
//! }
2119
//! ```
20+
//! extern crate bytesize;
21+
//!
22+
//! use bytesize::ByteSize;
23+
//!
24+
//! let x = ByteSize::mb(1);
25+
//! let y = ByteSize::kb(100);
2226
//!
23-
//! It also provides its human readable string as follows:
27+
//! let sum = x + y;
28+
//! assert_eq!(sum, ByteSize::kb(1100));
2429
//!
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));
30+
//! let product = 10u32 * x;
31+
//! assert_eq!(product, ByteSize::mb(10));
2832
//! ```
2933
3034
#[cfg(feature = "serde")]

0 commit comments

Comments
 (0)