hull

Function hull 

Source
pub fn hull<T: Copy + PartialOrd>(a: Interval<T>, b: Interval<T>) -> Interval<T>
Expand description

Calculate the union of the two Intervals. Note: it is called hull because it does not match the precise definition of a union of sets.

  • a, b the Intervals.

returns the union the the Intervals.

ยงExamples

use generic_interval::{Interval, hull};

#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct Metres(pub f64);

let a = Interval::try_from((Metres(1.0), Metres(4.0))).unwrap();
let b = Interval::try_from((Metres(6.0), Metres(9.0))).unwrap();

let result = hull(a, b);
assert_eq!(Metres(1.0), result.lower());
assert_eq!(Metres(9.0), result.upper());