Structure for ordering, need to implement for serde_json::Value.
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::parser::Filter;
|
||||
use crate::renderer::errors::RenderError;
|
||||
use crate::renderer::errors::WalkError;
|
||||
use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
use std::{cmp::Ordering, fmt::Debug};
|
||||
|
||||
pub trait ContextElement:
|
||||
Debug + Walkable + Renderable + Loopable + CloneIntoBoxedContextElement + CompareContextElement
|
||||
@@ -36,6 +36,8 @@ pub trait CastToAny {
|
||||
|
||||
pub trait CompareContextElement: CastToAny {
|
||||
fn equals(&self, other: &dyn ContextElement) -> bool;
|
||||
|
||||
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering>;
|
||||
}
|
||||
|
||||
pub trait CloneIntoBoxedContextElement {
|
||||
@@ -59,3 +61,9 @@ impl<'a, 'b> PartialEq<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||
self.equals(*other)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> PartialOrd<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||
fn partial_cmp(&self, other: &&'b dyn ContextElement) -> Option<Ordering> {
|
||||
self.partial_compare(*other)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user