Skip to content

j5ik2o/intervals-rs

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages