diff options
author | René Kijewski <kijewski@library.vetmed.fu-berlin.de> | 2022-01-12 14:25:58 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-01-24 13:28:53 +0100 |
commit | bb7c60ece5dcfea9d31f79f445f80fdd4e0bf3ca (patch) | |
tree | d687cb8ba6c0d8fcaecfc97076fa24df887dac59 /askama_shared/src/generator.rs | |
parent | 86fd2f4f8b1e32803fd7acc43e98dbbb137156b5 (diff) | |
download | askama-bb7c60ece5dcfea9d31f79f445f80fdd4e0bf3ca.tar.gz askama-bb7c60ece5dcfea9d31f79f445f80fdd4e0bf3ca.tar.bz2 askama-bb7c60ece5dcfea9d31f79f445f80fdd4e0bf3ca.zip |
Replace `&PathBuf` with `&Path`
PathBuf is to String like Path is to str, so `&PathBuf` is a pointer to
a pointer. Clippy does not likes that.
Diffstat (limited to 'askama_shared/src/generator.rs')
-rw-r--r-- | askama_shared/src/generator.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index 437331c..53729c6 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -9,24 +9,24 @@ use proc_macro2::Span; use quote::{quote, ToTokens}; use std::collections::HashMap; -use std::path::PathBuf; +use std::path::Path; use std::{cmp, hash, mem, str}; pub fn generate<S: std::hash::BuildHasher>( input: &TemplateInput<'_>, - contexts: &HashMap<&PathBuf, Context<'_>, S>, + contexts: &HashMap<&Path, Context<'_>, S>, heritage: Option<&Heritage<'_>>, integrations: Integrations, ) -> Result<String, CompileError> { Generator::new(input, contexts, heritage, integrations, MapChain::new()) - .build(&contexts[&input.path]) + .build(&contexts[input.path.as_path()]) } 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>, S>, + contexts: &'a HashMap<&'a Path, Context<'a>, S>, // The heritage contains references to blocks and their ancestry heritage: Option<&'a Heritage<'a>>, // What integrations need to be generated @@ -51,7 +51,7 @@ struct Generator<'a, S: std::hash::BuildHasher> { impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { fn new<'n>( input: &'n TemplateInput<'_>, - contexts: &'n HashMap<&'n PathBuf, Context<'n>, S>, + contexts: &'n HashMap<&'n Path, Context<'n>, S>, heritage: Option<&'n Heritage<'_>>, integrations: Integrations, locals: MapChain<'n, &'n str, LocalMeta>, @@ -134,7 +134,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { // Skip the fake path of templates defined in rust source. let path_is_valid = match self.input.source { Source::Path(_) => true, - Source::Source(_) => *path != &self.input.path, + Source::Source(_) => path != &self.input.path, }; if path_is_valid { let path = path.to_str().unwrap(); @@ -669,7 +669,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { let path = ctx.imports.get(s).ok_or_else(|| { CompileError::String(format!("no import found for scope '{}'", s)) })?; - let mctx = self.contexts.get(path).ok_or_else(|| { + let mctx = self.contexts.get(path.as_path()).ok_or_else(|| { CompileError::String(format!("context for '{:?}' not found", path)) })?; ( |