Manual equals is working!

This commit is contained in:
Tom Alexander 2020-05-10 22:14:07 -04:00
parent 2fb7ca9db7
commit 6261f7881c
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 21 additions and 1 deletions

View File

@ -143,6 +143,26 @@ impl Loopable for serde_json::Value {
impl CompareContextElement for serde_json::Value {
fn equals(&self, other: &dyn ContextElement) -> bool {
false
match self {
serde_json::Value::Null => false,
serde_json::Value::Bool(boolean) => false,
serde_json::Value::Number(_num) => false,
serde_json::Value::String(string_value) => {
// Handle json string
match other.to_any().downcast_ref::<Self>() {
None => (),
Some(other_json_value) => return self == other_json_value,
}
// Handle rust string (for string literals)
match other.to_any().downcast_ref::<String>() {
None => (),
Some(other_string) => return string_value == other_string,
}
// Otherwise we know of no other string types
false
}
serde_json::Value::Array(array_value) => false,
serde_json::Value::Object(_obj) => false,
}
}
}