A Rust crate for intervals.
Add this to your Cargo.toml
:
toml
[dependencies]
intervals-rs = "<<version>>"
rust
let ex_range = Interval::over(
LimitValue::Limit(Decimal::from_f32(-5.5).unwrap()),
false,
LimitValue::Limit(Decimal::from_f32(6.6).unwrap()),
true,
);
assert!(ex_range.includes(&LimitValue::Limit(Decimal::from_f32(5.0).unwrap())));
assert!(!ex_range.includes(&LimitValue::Limit(Decimal::from_f32(-5.5).unwrap())));
assert!(ex_range.includes(&LimitValue::Limit(Decimal::from_f32(-5.4999).unwrap())));
assert!(ex_range.includes(&LimitValue::Limit(Decimal::from_f32(6.6).unwrap())));
assert!(!ex_range.includes(&LimitValue::Limit(Decimal::from_f32(6.601).unwrap())));
assert!(!ex_range.includes(&LimitValue::Limit(Decimal::from_f32(-5.501).unwrap())));
rust
let range = Interval::closed(
LimitValue::Limit(Decimal::from_f32(-5.5).unwrap()),
LimitValue::Limit(Decimal::from_f32(6.6).unwrap()),
);
assert!(range.includes(&LimitValue::Limit(Decimal::from_f32(5.0).unwrap())));
assert!(range.includes(&LimitValue::Limit(Decimal::from_f32(-5.5).unwrap())));
assert!(range.includes(&LimitValue::Limit(Decimal::from_f32(-5.4999).unwrap())));
assert!(range.includes(&LimitValue::Limit(Decimal::from_f32(6.6).unwrap())));
assert!(!range.includes(&LimitValue::Limit(Decimal::from_f32(6.601).unwrap())));
assert!(!range.includes(&LimitValue::Limit(Decimal::from_f32(-5.501).unwrap())));
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.