I have broken the comparison function.
This commit is contained in:
parent
5b656a44ad
commit
4d28120732
20
src/bin.rs
20
src/bin.rs
@ -410,18 +410,21 @@ impl CompareContextElement for serde_json::Value {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle literals
|
// Handle literals
|
||||||
match other.to_any().downcast_ref::<OwnedLiteral>() {
|
match (self, other.to_any().downcast_ref::<OwnedLiteral>()) {
|
||||||
None => (),
|
(_, None) => (),
|
||||||
Some(OwnedLiteral::LString(text)) => {
|
(serde_json::Value::String(self_text), Some(OwnedLiteral::LString(other_text))) => {
|
||||||
|
return self_text.partial_cmp(other_text);
|
||||||
|
}
|
||||||
|
(_, Some(OwnedLiteral::LString(text))) => {
|
||||||
return self.to_string().partial_cmp(text);
|
return self.to_string().partial_cmp(text);
|
||||||
}
|
}
|
||||||
Some(OwnedLiteral::LPositiveInteger(other_num)) => {
|
(_, Some(OwnedLiteral::LPositiveInteger(other_num))) => {
|
||||||
let other_json_num: serde_json::Number = std::convert::From::from(*other_num);
|
let other_json_num: serde_json::Number = std::convert::From::from(*other_num);
|
||||||
return self.partial_compare(
|
return self.partial_compare(
|
||||||
&serde_json::Value::Number(other_json_num) as &dyn ContextElement
|
&serde_json::Value::Number(other_json_num) as &dyn ContextElement
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(OwnedLiteral::LFloat(other_num)) => {
|
(_, Some(OwnedLiteral::LFloat(other_num))) => {
|
||||||
let other_json_num = serde_json::Number::from_f64(*other_num);
|
let other_json_num = serde_json::Number::from_f64(*other_num);
|
||||||
match other_json_num {
|
match other_json_num {
|
||||||
None => return None,
|
None => return None,
|
||||||
@ -483,6 +486,13 @@ impl From<&OwnedLiteral> for JsonNumber {
|
|||||||
match original {
|
match original {
|
||||||
OwnedLiteral::LPositiveInteger(num) => JsonNumber::UnsignedInteger(*num),
|
OwnedLiteral::LPositiveInteger(num) => JsonNumber::UnsignedInteger(*num),
|
||||||
OwnedLiteral::LString(text) => text.into(),
|
OwnedLiteral::LString(text) => text.into(),
|
||||||
|
OwnedLiteral::LFloat(num) => {
|
||||||
|
if num.is_nan() {
|
||||||
|
JsonNumber::Failure
|
||||||
|
} else {
|
||||||
|
JsonNumber::Decimal(*num)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user