generic-interval
A generic closed interval library.
An interval is a pair of numbers which represents all the numbers between them.
Intervals are considered closed so the bounds are included.
Intervals are written [a, b] to represent all the numbers between a and b inclusive, a ≤ b.
The library is designed to be used with any types that implement the
Copy and PartialOrd traits including the floating point types:
f64 and f32 and arithmetic types in
new types.
The library is declared no_std so it can be used in embedded applications.
Examples
use ;
// An example new-type based on f64
;
let a = try_from.unwrap;
let b = try_from.unwrap;
// Note: the hull includes 4.0-6.0
let result = hull;
assert_eq!;
assert_eq!;
// Note: overlap may return an empty interval
// while overlaps is the same as intersection
let result = intersection;
assert!;
let result = overlaps;
assert!;
let result = overlap;
assert!;
let c = try_from.unwrap;
let result = intersection.unwrap;
assert_eq!;
assert_eq!;
License
generic-interval is provided under a MIT license, see LICENSE.