aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-16 20:38:58 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-16 20:38:58 +0200
commit39b9e6e491919d1f4e7f79bf78e79da43d4d003b (patch)
treef2647f9992cae2a6451e92bd2d6bf44f46b75400 /askama_derive
parent5548cb1f4adb3a1ec2f0232ef140843f12c9a8af (diff)
downloadaskama-39b9e6e491919d1f4e7f79bf78e79da43d4d003b.tar.gz
askama-39b9e6e491919d1f4e7f79bf78e79da43d4d003b.tar.bz2
askama-39b9e6e491919d1f4e7f79bf78e79da43d4d003b.zip
Use reference into AST for template path instead of cloning
Diffstat (limited to 'askama_derive')
-rw-r--r--askama_derive/src/lib.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 4e07819..cf7f91f 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -45,7 +45,7 @@ fn build_template(ast: &syn::DeriveInput) -> String {
// Returns a `TemplateMeta` based on the `template()` attribute data found
// in the parsed struct or enum. Will panic if it does not find the required
// template path, or if the `print` key has an unexpected value.
-fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
+fn get_template_meta<'a>(ast: &'a syn::DeriveInput) -> TemplateMeta<'a> {
let attr = ast.attrs.iter().find(|a| a.name() == "template");
if attr.is_none() {
let msg = format!("'template' attribute not found on struct '{}'",
@@ -62,7 +62,7 @@ fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
if let syn::MetaItem::NameValue(ref key, ref val) = *item {
match key.as_ref() {
"path" => if let syn::Lit::Str(ref s, _) = *val {
- path = Some(s.clone());
+ path = Some(s.as_ref());
} else {
panic!("template path must be string literal");
},
@@ -84,8 +84,8 @@ fn get_template_meta(ast: &syn::DeriveInput) -> TemplateMeta {
}
// Holds metadata for the template, based on the `template()` attribute.
-struct TemplateMeta {
- path: String,
+struct TemplateMeta<'a> {
+ path: &'a str,
print: Print,
}