Add that check to the not-equals helper and update the json value implementation to mark all non-scalars as not-equals.

This commit is contained in:
Tom Alexander
2020-05-16 15:30:17 -04:00
parent 41e4874d75
commit 7d4cb14530
2 changed files with 23 additions and 1 deletions

View File

@@ -145,7 +145,15 @@ impl CompareContextElement for serde_json::Value {
// Handle other serde_json::Value
match other.to_any().downcast_ref::<Self>() {
None => (),
Some(other_json_value) => return self == other_json_value,
Some(other_json_value) => match (self, other_json_value) {
// Non-scalar values not caught in the renderer by the
// identical-path shortcut are always not equal.
(serde_json::Value::Array(_), _)
| (_, serde_json::Value::Array(_))
| (serde_json::Value::Object(_), _)
| (_, serde_json::Value::Object(_)) => return false,
_ => return self == other_json_value,
},
}
// Handle string literals
match other.to_any().downcast_ref::<String>() {