map equality considers both key and value

This commit is contained in:
Connor Skees 2020-07-07 10:55:37 -04:00
parent 790573195f
commit b56a4a3fcc
2 changed files with 7 additions and 2 deletions

View File

@ -16,8 +16,8 @@ pub(crate) struct SassMap(Vec<(Value, Value)>);
impl PartialEq for SassMap { impl PartialEq for SassMap {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
let set_one: HashSet<&Value> = self.0.iter().map(|(v1, _)| v1).collect(); let set_one: HashSet<&(Value, Value)> = self.0.iter().collect();
let set_two: HashSet<&Value> = other.0.iter().map(|(v1, _)| v1).collect(); let set_two: HashSet<&(Value, Value)> = other.0.iter().collect();
set_one == set_two set_one == set_two
} }
} }

View File

@ -192,3 +192,8 @@ test!(
"a {\n color: (c: d, a: b)==(a: b, c: d);\n}\n", "a {\n color: (c: d, a: b)==(a: b, c: d);\n}\n",
"a {\n color: true;\n}\n" "a {\n color: true;\n}\n"
); );
test!(
map_equality_considers_both_key_and_value,
"a {\n color: (a: b)==(a: c);\n}\n",
"a {\n color: false;\n}\n"
);