aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/input.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-05 20:37:52 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-05 20:37:52 +0200
commit4154f4ebf33f1cf90ca8b93798baca26813b08d0 (patch)
tree770057cbac731b6be3ed87c1b28fd8e3d95a2fd2 /askama_shared/src/input.rs
parent7203fac07cabe68047033a75ddb2db417a9ef6c6 (diff)
downloadaskama-4154f4ebf33f1cf90ca8b93798baca26813b08d0.tar.gz
askama-4154f4ebf33f1cf90ca8b93798baca26813b08d0.tar.bz2
askama-4154f4ebf33f1cf90ca8b93798baca26813b08d0.zip
Refactor type handling for attribute parameters
Diffstat (limited to 'askama_shared/src/input.rs')
-rw-r--r--askama_shared/src/input.rs16
1 files changed, 8 insertions, 8 deletions
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,