[go: up one dir, main page]

ubyte 0.10.4

A simple, complete, const-everything, saturating, human-friendly, no_std library for byte units.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[cfg(feature = "serde")]
#[test]
fn str_is_accepted() {
    let input = r#""42 KiB""#;

    let actual = serde_json::from_str::<ubyte::ByteUnit>(&input).unwrap();
    assert_eq!(actual.as_u64(), 42 * 1024);
}

#[cfg(feature = "serde")]
#[test]
fn u64_bytes_is_accepted() {
    let input = r#"42"#;

    let actual = serde_json::from_str::<ubyte::ByteUnit>(&input).unwrap();
    assert_eq!(actual, 42);
}