Fix cargo fmt

This commit is contained in:
Juan Aguilar Santillana 2018-12-07 19:47:33 +01:00 committed by Dirkjan Ochtman
parent 93136a66ed
commit cdafc8d641
6 changed files with 65 additions and 55 deletions

View File

@ -506,6 +506,7 @@ pub fn rerun_if_templates_changed() {
for template_dir in &shared::Config::new(&file).dirs {
visit_dirs(template_dir, &|e: &DirEntry| {
println!("cargo:rerun-if-changed={}", e.path().to_str().unwrap());
}).unwrap();
})
.unwrap();
}
}

View File

@ -240,7 +240,8 @@ impl<'a> Generator<'a> {
target,
self.input.ast.ident,
quote!(#orig_ty_generics #where_clause),
).as_ref(),
)
.as_ref(),
);
}
@ -645,9 +646,7 @@ impl<'a> Generator<'a> {
let mut expr_buf = Buffer::new(0);
let wrapped = self.visit_expr(&mut expr_buf, s);
let expression = match (wrapped, &self.input.escaping) {
(Wrapped, &Html) | (Wrapped, &None) | (Unwrapped, &None) => {
expr_buf.buf
}
(Wrapped, &Html) | (Wrapped, &None) | (Unwrapped, &None) => expr_buf.buf,
(Unwrapped, &Html) => {
format!("::askama::MarkupDisplay::from(&{})", expr_buf.buf)
}
@ -1098,10 +1097,11 @@ where
}
}
fn contains(&self, val: T) -> bool {
self.scopes.iter().rev().any(|set| set.contains(&val)) || match self.parent {
Some(set) => set.contains(val),
None => false,
}
self.scopes.iter().rev().any(|set| set.contains(&val))
|| match self.parent {
Some(set) => set.contains(val),
None => false,
}
}
fn insert(&mut self, val: T) {
self.scopes.last_mut().unwrap().insert(val);

View File

@ -31,9 +31,11 @@ impl<'a> TemplateInput<'a> {
let mut meta = None;
for attr in &ast.attrs {
match attr.interpret_meta() {
Some(m) => if m.name() == "template" {
meta = Some(m)
},
Some(m) => {
if m.name() == "template" {
meta = Some(m)
}
}
None => {
let mut tokens = TokenStream::new();
attr.to_tokens(&mut tokens);
@ -59,42 +61,54 @@ impl<'a> TemplateInput<'a> {
if let syn::NestedMeta::Meta(ref item) = nm_item {
if let syn::Meta::NameValue(ref pair) = item {
match pair.ident.to_string().as_ref() {
"path" => if let syn::Lit::Str(ref s) = pair.lit {
if source.is_some() {
panic!("must specify 'source' or 'path', not both");
"path" => {
if let syn::Lit::Str(ref s) = pair.lit {
if source.is_some() {
panic!("must specify 'source' or 'path', not both");
}
source = Some(Source::Path(s.value()));
} else {
panic!("template path must be string literal");
}
source = Some(Source::Path(s.value()));
} else {
panic!("template path must be string literal");
},
"source" => if let syn::Lit::Str(ref s) = pair.lit {
if source.is_some() {
panic!("must specify 'source' or 'path', not both");
}
"source" => {
if let syn::Lit::Str(ref s) = pair.lit {
if source.is_some() {
panic!("must specify 'source' or 'path', not both");
}
source = Some(Source::Source(s.value()));
} else {
panic!("template source must be string literal");
}
source = Some(Source::Source(s.value()));
} else {
panic!("template source must be string literal");
},
"print" => if let syn::Lit::Str(ref s) = pair.lit {
print = s.value().into();
} else {
panic!("print value must be string literal");
},
"escape" => if let syn::Lit::Str(ref s) = pair.lit {
escaping = Some(s.value().into());
} else {
panic!("escape value must be string literal");
},
"ext" => if let syn::Lit::Str(ref s) = pair.lit {
ext = Some(s.value());
} else {
panic!("ext value must be string literal");
},
"syntax" => if let syn::Lit::Str(ref s) = pair.lit {
syntax = Some(s.value())
} else {
panic!("syntax value must be string literal");
},
}
"print" => {
if let syn::Lit::Str(ref s) = pair.lit {
print = s.value().into();
} else {
panic!("print value must be string literal");
}
}
"escape" => {
if let syn::Lit::Str(ref s) = pair.lit {
escaping = Some(s.value().into());
} else {
panic!("escape value must be string literal");
}
}
"ext" => {
if let syn::Lit::Str(ref s) = pair.lit {
ext = Some(s.value());
} else {
panic!("ext value must be string literal");
}
}
"syntax" => {
if let syn::Lit::Str(ref s) = pair.lit {
syntax = Some(s.value())
} else {
panic!("syntax value must be string literal");
}
}
attr => panic!("unsupported annotation key '{}' found", attr),
}
}

View File

@ -189,7 +189,8 @@ impl<'a> Context<'a> {
} else {
unreachable!()
}
}).collect();
})
.collect();
Context {
nodes,

View File

@ -164,10 +164,7 @@ fn test_filter_let_filter() {
}
#[derive(Template)]
#[template(
source = "{{ foo|truncate(10) }}{{ foo|truncate(5) }}",
ext = "txt"
)]
#[template(source = "{{ foo|truncate(10) }}{{ foo|truncate(5) }}", ext = "txt")]
struct TruncateFilter {
foo: String,
}

View File

@ -222,10 +222,7 @@ enum Alphabet {
}
#[derive(Template)]
#[template(
source = "{% if x == Alphabet::Alpha %}true{% endif %}",
ext = "txt"
)]
#[template(source = "{% if x == Alphabet::Alpha %}true{% endif %}", ext = "txt")]
struct PathCompareTemplate {
x: Alphabet,
}