Starting an IntoContextElement trait to allow for delayed evaluation.

This commit is contained in:
Tom Alexander
2020-05-30 16:34:32 -04:00
parent 581f9f7e97
commit 975ab278ef
5 changed files with 53 additions and 1 deletions

View File

@@ -1,7 +1,8 @@
use crate::parser::KVPair;
use crate::parser::{Filter, OwnedLiteral, RValue};
use crate::parser::{Filter, OwnedLiteral, PartialNameElement, RValue};
use crate::renderer::context_element::CompareContextElement;
use crate::renderer::context_element::ContextElement;
use crate::renderer::context_element::IntoContextElement;
use crate::renderer::walking::walk_path;
use crate::renderer::Loopable;
use crate::renderer::RenderError;
@@ -37,6 +38,9 @@ impl From<&RValue<'_>> for OwnedRValue {
fn from(original: &RValue<'_>) -> Self {
match original {
RValue::RVLiteral(literal) => OwnedRValue::RVLiteral(literal.clone()),
RValue::RVTemplate(template) => {
OwnedRValue::RVLiteral(OwnedLiteral::LString("TODO".to_owned()))
}
RValue::RVPath(path) => OwnedRValue::RVPath(OwnedPath {
keys: path.keys.iter().map(|k| k.to_string()).collect(),
}),
@@ -232,3 +236,9 @@ impl CompareContextElement for OwnedLiteral {
}
}
}
impl IntoContextElement for Vec<PartialNameElement> {
fn into_context_element(&self) -> &dyn ContextElement {
&OwnedLiteral::LPositiveInteger(1)
}
}