Skip to content

Commit 81260e6

Browse files
authored
Fix hash for DrivenNet (#48)
* fix hashing for DrivenNet * bump ver
1 parent a45cbf3 commit 81260e6

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "safety-net"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
edition = "2024"
55
license = "MIT OR Apache-2.0"
66

src/netlist.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ where
10001000
}
10011001

10021002
/// Represent a net that is being driven by a [Instantiable]
1003-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1003+
#[derive(Debug, Clone)]
10041004
pub struct DrivenNet<I: Instantiable> {
10051005
pos: usize,
10061006
netref: NetRef<I>,
@@ -1125,6 +1125,27 @@ where
11251125
}
11261126
}
11271127

1128+
impl<I> PartialEq for DrivenNet<I>
1129+
where
1130+
I: Instantiable,
1131+
{
1132+
fn eq(&self, other: &Self) -> bool {
1133+
self.netref == other.netref && self.pos == other.pos
1134+
}
1135+
}
1136+
1137+
impl<I> Eq for DrivenNet<I> where I: Instantiable {}
1138+
1139+
impl<I> std::hash::Hash for DrivenNet<I>
1140+
where
1141+
I: Instantiable,
1142+
{
1143+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
1144+
self.netref.hash(state);
1145+
self.pos.hash(state);
1146+
}
1147+
}
1148+
11281149
impl<I> WeakIndex<usize> for Netlist<I>
11291150
where
11301151
I: Instantiable,

0 commit comments

Comments
 (0)