Switch the renderer over to using the new is_truthy value and add the injection of $idx and $len into the context tree.

This commit is contained in:
Tom Alexander
2020-05-24 16:57:24 -04:00
parent 966499db76
commit c09393da80
2 changed files with 76 additions and 38 deletions

View File

@@ -6,6 +6,7 @@ use crate::renderer::Renderable;
use crate::renderer::Truthiness;
use crate::renderer::WalkError;
use crate::{parser::Filter, parser::OwnedLiteral, renderer::Walkable};
use std::convert::TryInto;
use std::cmp::Ordering;
@@ -21,10 +22,11 @@ pub struct IterationContext {
}
impl IterationContext {
pub fn new(idx: u64, len: u64) -> Self {
pub fn new(idx: usize, len: usize) -> Self {
// TODO: it would be nice to handle usize vs u64 better
IterationContext {
idx: OwnedLiteral::LPositiveInteger(idx),
len: OwnedLiteral::LPositiveInteger(len),
idx: OwnedLiteral::LPositiveInteger(idx.try_into().unwrap()),
len: OwnedLiteral::LPositiveInteger(len.try_into().unwrap()),
}
}
}