mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 05:51:01 +00:00
json doesn't need an explicit PartialOrd impl
This commit is contained in:
@@ -245,7 +245,7 @@ use ser::Serializable;
|
|||||||
use ser;
|
use ser;
|
||||||
|
|
||||||
/// Represents a json value
|
/// Represents a json value
|
||||||
#[deriving(Clone, PartialEq)]
|
#[deriving(Clone, PartialEq, PartialOrd)]
|
||||||
pub enum Json {
|
pub enum Json {
|
||||||
Null,
|
Null,
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
@@ -2017,62 +2017,6 @@ macro_rules! expect(
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Test if two json values are less than one another
|
|
||||||
impl PartialOrd for Json {
|
|
||||||
fn lt(&self, other: &Json) -> bool {
|
|
||||||
match *self {
|
|
||||||
Number(f0) => {
|
|
||||||
match *other {
|
|
||||||
Number(f1) => f0 < f1,
|
|
||||||
String(_) | Boolean(_) | List(_) | Object(_) |
|
|
||||||
Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String(ref s0) => {
|
|
||||||
match *other {
|
|
||||||
Number(_) => false,
|
|
||||||
String(ref s1) => s0 < s1,
|
|
||||||
Boolean(_) | List(_) | Object(_) | Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean(b0) => {
|
|
||||||
match *other {
|
|
||||||
Number(_) | String(_) => false,
|
|
||||||
Boolean(b1) => b0 < b1,
|
|
||||||
List(_) | Object(_) | Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List(ref l0) => {
|
|
||||||
match *other {
|
|
||||||
Number(_) | String(_) | Boolean(_) => false,
|
|
||||||
List(ref l1) => (*l0) < (*l1),
|
|
||||||
Object(_) | Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object(ref d0) => {
|
|
||||||
match *other {
|
|
||||||
Number(_) | String(_) | Boolean(_) | List(_) => false,
|
|
||||||
Object(ref d1) => d0 < d1,
|
|
||||||
Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Null => {
|
|
||||||
match *other {
|
|
||||||
Number(_) | String(_) | Boolean(_) | List(_) |
|
|
||||||
Object(_) =>
|
|
||||||
false,
|
|
||||||
Null => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A trait for converting values to JSON
|
/// A trait for converting values to JSON
|
||||||
pub trait ToJson {
|
pub trait ToJson {
|
||||||
/// Converts the value of `self` to an instance of JSON
|
/// Converts the value of `self` to an instance of JSON
|
||||||
|
|||||||
Reference in New Issue
Block a user