From a47020d4d590507defd0393782ca65cff76295da Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 8 Feb 2017 20:30:32 +0100 Subject: Simplify derive_template() function --- askama_derive/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'askama_derive/src/lib.rs') 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() } -- cgit