ic/
iris.rs

1/// Iris functionalities that are independent of classification or lack of it.
2pub trait Iris {
3    // Required
4    fn sepal_length(&self) -> f32;
5    fn sepal_width(&self) -> f32;
6    fn petal_length(&self) -> f32;
7    fn petal_width(&self) -> f32;
8
9    // Provided
10    fn dist_sq(&self, other: &dyn Iris) -> f32 {
11        let lhs = self;
12        let rhs = other;
13        [
14            (lhs.sepal_length() - rhs.sepal_length()),
15            (lhs.sepal_width() - rhs.sepal_width()),
16            (lhs.petal_length() - rhs.petal_length()),
17            (lhs.petal_width() - rhs.petal_width()),
18        ]
19        .into_iter()
20        .map(|x| x * x)
21        .sum()
22    }
23}
24
25pub mod classified;
26pub mod params;
27pub mod species;
28pub mod unclassified;