rational_extensions 0.5.0

Extensions for rational numbers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use super::{Ratio, Rational};
#[test]
fn deserialize() {
    assert!(
        serde_json::from_str::<Rational::<u8>>(r#""2/3""#)
            .is_ok_and(|r| r.0 == Ratio::new(2u8, 3u8))
    );
    assert!(
        serde_json::from_str::<Rational::<u8>>(r#""0.67""#)
            .is_ok_and(|r| r.0 == Ratio::new(67u8, 100u8))
    );
}