I think I figured out how to get the Index trait back into the generic type.
This commit is contained in:
parent
f65a144b3c
commit
265afe7eeb
@ -43,9 +43,9 @@ impl<'a> DustRenderer<'a> {
|
|||||||
.insert(template.name.clone(), &template.template);
|
.insert(template.name.clone(), &template.template);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render<C>(&self, name: &str, context: C) -> Result<String, RenderError>
|
pub fn render<C>(&self, name: &str, context: &C) -> Result<String, RenderError>
|
||||||
where
|
where
|
||||||
C: Copy,
|
C: Index<&'a str>,
|
||||||
{
|
{
|
||||||
let main_template = match self.templates.get(name) {
|
let main_template = match self.templates.get(name) {
|
||||||
Some(tmpl) => tmpl,
|
Some(tmpl) => tmpl,
|
||||||
@ -58,9 +58,9 @@ impl<'a> DustRenderer<'a> {
|
|||||||
self.render_template(main_template, context)
|
self.render_template(main_template, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_template<C>(&self, template: &Template, context: C) -> Result<String, RenderError>
|
fn render_template<C>(&self, template: &Template, context: &C) -> Result<String, RenderError>
|
||||||
where
|
where
|
||||||
C: Copy,
|
C: Index<&'a str>,
|
||||||
{
|
{
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
for elem in &template.contents.elements {
|
for elem in &template.contents.elements {
|
||||||
@ -74,9 +74,9 @@ impl<'a> DustRenderer<'a> {
|
|||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_tag<C>(&self, tag: &DustTag, context: C) -> Result<String, RenderError>
|
fn render_tag<C>(&self, tag: &DustTag, context: &C) -> Result<String, RenderError>
|
||||||
where
|
where
|
||||||
C: Copy,
|
C: Index<&'a str>,
|
||||||
{
|
{
|
||||||
match tag {
|
match tag {
|
||||||
DustTag::DTComment(comment) => (),
|
DustTag::DTComment(comment) => (),
|
||||||
|
Loading…
Reference in New Issue
Block a user