Generic implementation of CompareContextElement.
This commit is contained in:
parent
256051220d
commit
32abe41e1a
13
src/bin.rs
13
src/bin.rs
@ -140,16 +140,3 @@ impl Loopable for serde_json::Value {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareContextElement for serde_json::Value {
|
|
||||||
fn to_any(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn equals(&self, other: &dyn ContextElement) -> bool {
|
|
||||||
other
|
|
||||||
.to_any()
|
|
||||||
.downcast_ref::<Self>()
|
|
||||||
.map_or(false, |a| self == a)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -46,6 +46,19 @@ impl<C: 'static + ContextElement + Clone> CloneIntoBoxedContextElement for C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<C: 'static + ContextElement + PartialEq> CompareContextElement for C {
|
||||||
|
fn to_any(&self) -> &dyn Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn equals(&self, other: &dyn ContextElement) -> bool {
|
||||||
|
other
|
||||||
|
.to_any()
|
||||||
|
.downcast_ref::<Self>()
|
||||||
|
.map_or(false, |a| self == a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, 'b> PartialEq<&'b dyn ContextElement> for &'a dyn ContextElement {
|
impl<'a, 'b> PartialEq<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||||
fn eq(&self, other: &&'b dyn ContextElement) -> bool {
|
fn eq(&self, other: &&'b dyn ContextElement) -> bool {
|
||||||
self.equals(*other)
|
self.equals(*other)
|
||||||
|
@ -142,16 +142,3 @@ impl Walkable for String {
|
|||||||
Err(WalkError::CantWalk)
|
Err(WalkError::CantWalk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareContextElement for String {
|
|
||||||
fn to_any(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn equals(&self, other: &dyn ContextElement) -> bool {
|
|
||||||
other
|
|
||||||
.to_any()
|
|
||||||
.downcast_ref::<Self>()
|
|
||||||
.map_or(false, |a| self == a)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user