aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 20:30:32 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-02-08 20:30:32 +0100
commita47020d4d590507defd0393782ca65cff76295da (patch)
tree8557664521215759ec6ab5447b61de265eacbdc9 /askama_derive/src/lib.rs
parent330e2ef471e07dbb242bf402001f69e5c0cd2701 (diff)
downloadaskama-a47020d4d590507defd0393782ca65cff76295da.tar.gz
askama-a47020d4d590507defd0393782ca65cff76295da.tar.bz2
askama-a47020d4d590507defd0393782ca65cff76295da.zip
Simplify derive_template() function
Diffstat (limited to 'askama_derive/src/lib.rs')
-rw-r--r--askama_derive/src/lib.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs
index 244c43b..367f124 100644
--- a/askama_derive/src/lib.rs
+++ b/askama_derive/src/lib.rs
@@ -21,14 +21,11 @@ fn get_path_from_attrs(attrs: &[syn::Attribute]) -> String {
#[proc_macro_derive(Template, attributes(template))]
pub fn derive_template(input: TokenStream) -> TokenStream {
- let source = input.to_string();
-
- let ast = syn::parse_derive_input(&source).unwrap();
- let _ctx = match ast.body {
+ let ast = syn::parse_derive_input(&input.to_string()).unwrap();
+ match ast.body {
syn::Body::Struct(ref data) => data,
_ => panic!("#[derive(Template)] can only be used with structs"),
};
-
let path = get_path_from_attrs(&ast.attrs);
askama::build_template(&path, &ast).parse().unwrap()
}