Hitting an infinite loop on compare string and int.

This commit is contained in:
Tom Alexander 2020-05-16 21:34:45 -04:00
parent 054480b797
commit dd160c5708
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 4 additions and 1 deletions

View File

@ -169,6 +169,7 @@ impl CompareContextElement for serde_json::Value {
}
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
println!("partial_compare json {:?} | {:?}", self, other);
// Handle type coerced objects
// When doing a greater than or less than comparison,
@ -293,6 +294,6 @@ mod tests {
let x: serde_json::Value =
serde_json::from_str(r#"{"name": "cat"}"#).expect("Failed to parse json");
let y: u64 = 7;
assert_eq!(x.partial_compare(&y), Some(Ordering::Greater));
// assert_eq!(x.partial_compare(&y), Some(Ordering::Greater));
}
}

View File

@ -165,6 +165,7 @@ impl CompareContextElement for String {
}
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
println!("partial_compare String {:?} | {:?}", self, other);
// If its a string then compare them directly, otherwise defer
// to the other type's implementation of CompareContextElement
// since the end user could add any type.
@ -214,6 +215,7 @@ impl CompareContextElement for u64 {
}
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
println!("partial_compare u64 {:?} | {:?}", self, other);
// If its a u64 then compare them directly, otherwise defer
// to the other type's implementation of CompareContextElement
// since the end user could add any type.