Readability order
This commit is contained in:
parent
d8ca7344fa
commit
e075224f9a
1 changed files with 26 additions and 26 deletions
|
|
@ -118,6 +118,32 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Data {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.cmp(other) == Ordering::Equal
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Data {}
|
||||
|
||||
impl PartialOrd for Data {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for Data {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match (self, other) {
|
||||
(Data::Value(l), Data::Value(r)) => l.cmp(r),
|
||||
(Data::List(l), Data::List(r)) => Data::zip_cmp(l, r),
|
||||
|
||||
(Data::Value(_), Data::List(_)) => self.to_list().cmp(other),
|
||||
(Data::List(_), Data::Value(_)) => self.cmp(&other.to_list()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Data {
|
||||
fn to_list(&self) -> Self {
|
||||
match self {
|
||||
|
|
@ -146,32 +172,6 @@ impl Data {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Data {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.cmp(other) == Ordering::Equal
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Data {}
|
||||
|
||||
impl PartialOrd for Data {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for Data {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match (self, other) {
|
||||
(Data::Value(l), Data::Value(r)) => l.cmp(r),
|
||||
(Data::List(l), Data::List(r)) => Data::zip_cmp(l, r),
|
||||
|
||||
(Data::Value(_), Data::List(_)) => self.to_list().cmp(other),
|
||||
(Data::List(_), Data::Value(_)) => self.cmp(&other.to_list()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Data {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue