algae_graph/cmp/
pair.rs

1/*
2    Appellation: pair <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4    Description: a pair can either be scalar or vector; if vector, than direction matters
5*/
6use serde::{Deserialize, Serialize};
7
8#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
9pub struct Pair<T>(pub T, pub T)
10where
11    T: Default;
12
13impl<T> Pair<T>
14where
15    T: Default,
16{
17    pub fn new(a: T, b: T) -> Self {
18        Self(a, b)
19    }
20}
21
22impl<T> From<(T, T)> for Pair<T>
23where
24    T: Default,
25{
26    fn from(data: (T, T)) -> Self {
27        Self(data.0, data.1)
28    }
29}