From 4154f4ebf33f1cf90ca8b93798baca26813b08d0 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 5 Sep 2017 20:37:52 +0200 Subject: Refactor type handling for attribute parameters --- askama_shared/src/input.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'askama_shared/src') diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs index 40dc39f..43aa400 100644 --- a/askama_shared/src/input.rs +++ b/askama_shared/src/input.rs @@ -64,12 +64,12 @@ impl<'a> TemplateMeta<'a> { panic!("template source must be string literal"); }, "print" => if let syn::Lit::Str(ref s, _) = *val { - print = s.into(); + print = (s.as_ref() as &str).into(); } else { panic!("print value must be string literal"); }, "escape" => if let syn::Lit::Str(ref s, _) = *val { - escaping = s.into(); + escaping = (s.as_ref() as &str).into(); } else { panic!("escape value must be string literal"); }, @@ -98,10 +98,10 @@ pub enum EscapeMode { None, } -impl<'a> From<&'a String> for EscapeMode { - fn from(s: &'a String) -> EscapeMode { +impl<'a> From<&'a str> for EscapeMode { + fn from(s: &'a str) -> EscapeMode { use self::EscapeMode::*; - match s.as_ref() { + match s { "html" => Html, "none" => None, v => panic!("invalid value for escape option: {}", v), @@ -117,10 +117,10 @@ pub enum Print { None, } -impl<'a> From<&'a String> for Print { - fn from(s: &'a String) -> Print { +impl<'a> From<&'a str> for Print { + fn from(s: &'a str) -> Print { use self::Print::*; - match s.as_ref() { + match s { "all" => All, "ast" => Ast, "code" => Code, -- cgit