Generic implementation of CloneIntoBoxedContextElement.
This commit is contained in:
@@ -5,7 +5,7 @@ use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub trait ContextElement:
|
||||
Debug + Walkable + Renderable + Loopable + IntoBoxedContextElement + CompareContextElement
|
||||
Debug + Walkable + Renderable + Loopable + CloneIntoBoxedContextElement + CompareContextElement
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,10 +36,16 @@ pub trait CompareContextElement {
|
||||
fn equals(&self, other: &dyn ContextElement) -> bool;
|
||||
}
|
||||
|
||||
pub trait IntoBoxedContextElement {
|
||||
pub trait CloneIntoBoxedContextElement {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement>;
|
||||
}
|
||||
|
||||
impl<C: 'static + ContextElement + Clone> CloneIntoBoxedContextElement for C {
|
||||
fn clone_to_box(&self) -> Box<dyn ContextElement> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> PartialEq<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||
fn eq(&self, other: &&'b dyn ContextElement) -> bool {
|
||||
self.equals(*other)
|
||||
|
||||
Reference in New Issue
Block a user