From 20803616dc3ecea0f770fb6a0e4b6eb73f598dd6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 7 Sep 2017 20:42:54 +0200 Subject: Refactor creation of TemplateMeta value --- askama_shared/src/input.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs index 371cf6d..95233d3 100644 --- a/askama_shared/src/input.rs +++ b/askama_shared/src/input.rs @@ -99,21 +99,17 @@ impl<'a> TemplateMeta<'a> { } } - match source { - Some(s) => { - match (&s, ext.is_some()) { - (&Source::Path(_), true) => { - panic!("'ext' attribute cannot be used with 'path' attribute") - }, - (&Source::Source(_), false) => { - panic!("must include 'ext' attribute when using 'source' attribute") - }, - _ => {}, - } - TemplateMeta { source: s, print, escaping, ext } + let source = source.expect("template path or source not found in attributes"); + match (&source, ext.is_some()) { + (&Source::Path(_), true) => { + panic!("'ext' attribute cannot be used with 'path' attribute") + }, + (&Source::Source(_), false) => { + panic!("must include 'ext' attribute when using 'source' attribute") }, - None => panic!("template path or source not found in struct attributes"), + _ => {}, } + TemplateMeta { source, print, escaping, ext } } } -- cgit