1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::hash::{Hash, Hasher};
use super::prelude::*;
#[derive(Debug)]
pub enum TerminalId<N: NetlistBase + ?Sized> {
PinId(N::PinId),
PinInstId(N::PinInstId),
}
impl<N: NetlistBase + ?Sized> Hash for TerminalId<N> {
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
TerminalId::PinId(p) => p.hash(state),
TerminalId::PinInstId(p) => p.hash(state)
}
}
}
impl<N: NetlistBase + ?Sized> Eq for TerminalId<N> {}
impl<N: NetlistBase + ?Sized> PartialEq for TerminalId<N> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::PinId(p1), Self::PinId(p2)) => p1 == p2,
(Self::PinInstId(p1), Self::PinInstId(p2)) => p1 == p2,
(_, _) => false
}
}
}
impl<N: NetlistBase + ?Sized> Clone for TerminalId<N>
where N::PinId: Clone, N::PinInstId: Clone {
fn clone(&self) -> Self {
match self {
TerminalId::PinId(p) => Self::PinId(p.clone()),
TerminalId::PinInstId(p) => Self::PinInstId(p.clone()),
}
}
}