5 releases

0.0.5 Feb 28, 2022
0.0.4 Jun 2, 2021
0.0.3 Jun 1, 2021
0.0.2 Jun 1, 2021
0.0.1 May 31, 2021

#1064 in Data structures

Download history 89/week @ 2024-07-21 128/week @ 2024-07-28 94/week @ 2024-08-04 91/week @ 2024-08-11 77/week @ 2024-08-18 92/week @ 2024-08-25 81/week @ 2024-09-01 80/week @ 2024-09-08 75/week @ 2024-09-15 62/week @ 2024-09-22 46/week @ 2024-09-29 54/week @ 2024-10-06 52/week @ 2024-10-13 48/week @ 2024-10-20 42/week @ 2024-10-27 49/week @ 2024-11-03

204 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

75KB
1.5K SLoC

intervals-rs

A Rust crate for intervals.

Workflow Status crates.io docs.rs dependency status tokei

Install to Cargo.toml

Add this to your Cargo.toml:

[dependencies]
intervals-rs = "<<version>>"

Usage

  • open interval
let range = Interval::over(
  LimitValue::Limit(Decimal::from_f32(-5.5).unwrap()),
  false,
  LimitValue::Limit(Decimal::from_f32(6.6).unwrap()),
  true,
);
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())));
  • closed interval
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())));

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~315KB