Put IntoContextElement everywhere. It compiles again.

This commit is contained in:
Tom Alexander
2020-05-30 17:50:27 -04:00
parent 975ab278ef
commit 917da5a073
7 changed files with 112 additions and 88 deletions

View File

@@ -21,7 +21,7 @@ pub trait Truthiness {
}
pub trait Walkable {
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError>;
fn walk(&self, segment: &str) -> Result<&dyn IntoContextElement, WalkError>;
/// If an element contains meta information and should not be
/// returned as the final result of a walk, this function should
@@ -61,11 +61,11 @@ pub trait CompareContextElement: CastToAny {
}
pub trait CloneIntoBoxedContextElement {
fn clone_to_box(&self) -> Box<dyn ContextElement>;
fn clone_to_box(&self) -> Box<dyn IntoContextElement>;
}
impl<C: 'static + ContextElement + Clone> CloneIntoBoxedContextElement for C {
fn clone_to_box(&self) -> Box<dyn ContextElement> {
impl<C: 'static + IntoContextElement + Clone> CloneIntoBoxedContextElement for C {
fn clone_to_box(&self) -> Box<dyn IntoContextElement> {
Box::new(self.clone())
}
}
@@ -98,12 +98,18 @@ impl<C: ContextElement> FromContextElement for C {
}
}
pub trait IntoContextElement {
fn into_context_element(&self) -> &dyn ContextElement;
pub trait IntoContextElement: Debug + Walkable + CloneIntoBoxedContextElement {
fn into_context_element(
&self,
breadcrumbs: &Vec<&dyn IntoContextElement>,
) -> &dyn ContextElement;
}
impl<C: ContextElement> IntoContextElement for C {
fn into_context_element(&self) -> &dyn ContextElement {
fn into_context_element(
&self,
breadcrumbs: &Vec<&dyn IntoContextElement>,
) -> &dyn ContextElement {
self
}
}