From f334e07b9e9f435a279ace92d56855c63ec1ad4e Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 29 Jan 2020 21:49:42 +0100 Subject: Generalize hashmap parameter as suggested by clippy --- askama_shared/src/generator.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'askama_shared') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 3171c38..dd33e12 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -16,9 +16,9 @@ use std::{cmp, hash, mem, str}; use syn; -pub fn generate( +pub fn generate( input: &TemplateInput, - contexts: &HashMap<&PathBuf, Context>, + contexts: &HashMap<&PathBuf, Context, S>, heritage: &Option, integrations: Integrations, ) -> String { @@ -26,11 +26,11 @@ pub fn generate( .build(&contexts[&input.path]) } -struct Generator<'a> { +struct Generator<'a, S: std::hash::BuildHasher> { // The template input state: original struct AST and attributes input: &'a TemplateInput<'a>, // All contexts, keyed by the package-relative template path - contexts: &'a HashMap<&'a PathBuf, Context<'a>>, + contexts: &'a HashMap<&'a PathBuf, Context<'a>, S>, // The heritage contains references to blocks and their ancestry heritage: &'a Option>, // What integrations need to be generated @@ -52,14 +52,14 @@ struct Generator<'a> { named: usize, } -impl<'a> Generator<'a> { +impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { fn new<'n>( input: &'n TemplateInput, - contexts: &'n HashMap<&'n PathBuf, Context<'n>>, + contexts: &'n HashMap<&'n PathBuf, Context<'n>, S>, heritage: &'n Option, integrations: Integrations, locals: SetChain<'n, &'n str>, - ) -> Generator<'n> { + ) -> Generator<'n, S> { Generator { input, contexts, @@ -74,7 +74,7 @@ impl<'a> Generator<'a> { } } - fn child(&mut self) -> Generator { + fn child(&mut self) -> Generator<'_, S> { let locals = SetChain::with_parent(&self.locals); Self::new( self.input, -- cgit