Starting an IntoContextElement trait to allow for delayed evaluation.
This commit is contained in:
@@ -12,6 +12,7 @@ pub trait ContextElement:
|
||||
+ Loopable
|
||||
+ CloneIntoBoxedContextElement
|
||||
+ CompareContextElement
|
||||
+ FromContextElement
|
||||
{
|
||||
}
|
||||
|
||||
@@ -86,3 +87,23 @@ impl<'a, 'b> PartialOrd<&'b dyn ContextElement> for &'a dyn ContextElement {
|
||||
self.partial_compare(*other)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FromContextElement {
|
||||
fn from_context_element(&self) -> &dyn IntoContextElement;
|
||||
}
|
||||
|
||||
impl<C: ContextElement> FromContextElement for C {
|
||||
fn from_context_element(&self) -> &dyn IntoContextElement {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IntoContextElement {
|
||||
fn into_context_element(&self) -> &dyn ContextElement;
|
||||
}
|
||||
|
||||
impl<C: ContextElement> IntoContextElement for C {
|
||||
fn into_context_element(&self) -> &dyn ContextElement {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user