mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Include values of Prefab and Pop in their Hash and Eq impls
This commit is contained in:
parent
a2eaf42f9e
commit
e979b2e69a
2 changed files with 12 additions and 5 deletions
|
|
@ -118,7 +118,6 @@ pub struct ZLevel<'a> {
|
|||
pub grid: ndarray::ArrayView<'a, Key, ndarray::Dim<[usize; 2]>>,
|
||||
}
|
||||
|
||||
// TODO: port to ast::Prefab<Constant>
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Prefab {
|
||||
pub path: String,
|
||||
|
|
@ -128,7 +127,7 @@ pub struct Prefab {
|
|||
|
||||
impl PartialEq for Prefab {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.path == other.path && self.vars.keys().eq(other.vars.keys())
|
||||
self.path == other.path && self.vars == other.vars
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +136,11 @@ impl Eq for Prefab {}
|
|||
impl std::hash::Hash for Prefab {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.path.hash(state);
|
||||
self.vars.keys().for_each(|key| {key.hash(state)});
|
||||
let mut items: Vec<_> = self.vars.iter().collect();
|
||||
items.sort_by_key(|&(k, _)| k);
|
||||
for kvp in items {
|
||||
kvp.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub struct Pop {
|
|||
|
||||
impl PartialEq for Pop {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.path == other.path && self.vars.keys().eq(other.vars.keys())
|
||||
self.path == other.path && self.vars == other.vars
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,11 @@ impl Eq for Pop {}
|
|||
impl std::hash::Hash for Pop {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.path.hash(state);
|
||||
self.vars.keys().for_each(|key| {key.hash(state)});
|
||||
let mut items: Vec<_> = self.vars.iter().collect();
|
||||
items.sort_by_key(|&(k, _)| k);
|
||||
for kvp in items {
|
||||
kvp.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue