I think I figured out how to get the Index trait back into the generic type.

This commit is contained in:
Tom Alexander 2020-04-11 18:49:47 -04:00
parent f65a144b3c
commit 265afe7eeb
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 6 additions and 6 deletions

View File

@ -43,9 +43,9 @@ impl<'a> DustRenderer<'a> {
.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
C: Copy,
C: Index<&'a str>,
{
let main_template = match self.templates.get(name) {
Some(tmpl) => tmpl,
@ -58,9 +58,9 @@ impl<'a> DustRenderer<'a> {
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
C: Copy,
C: Index<&'a str>,
{
let mut output = String::new();
for elem in &template.contents.elements {
@ -74,9 +74,9 @@ impl<'a> DustRenderer<'a> {
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
C: Copy,
C: Index<&'a str>,
{
match tag {
DustTag::DTComment(comment) => (),