diff options
author | Juan Aguilar Santillana <mhpoin@gmail.com> | 2018-12-07 19:47:33 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-12-07 20:18:16 +0100 |
commit | cdafc8d641632ed89fb6435bfebd70d27bfa74ba (patch) | |
tree | d3085568d68051e56a7a50526740457bffe9bb42 /askama_derive/src | |
parent | 93136a66edcddab7c7800ad487c29d2cb57b713b (diff) | |
download | askama-cdafc8d641632ed89fb6435bfebd70d27bfa74ba.tar.gz askama-cdafc8d641632ed89fb6435bfebd70d27bfa74ba.tar.bz2 askama-cdafc8d641632ed89fb6435bfebd70d27bfa74ba.zip |
Fix cargo fmt
Diffstat (limited to 'askama_derive/src')
-rw-r--r-- | askama_derive/src/generator.rs | 16 | ||||
-rw-r--r-- | askama_derive/src/input.rs | 88 | ||||
-rw-r--r-- | askama_derive/src/lib.rs | 3 |
3 files changed, 61 insertions, 46 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index a58f3a4..128811a 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -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); diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs index 95d0019..f4da43c 100644 --- a/askama_derive/src/input.rs +++ b/askama_derive/src/input.rs @@ -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" => { + 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"); + } + } + "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"); } - 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"); + } + "syntax" => { + if let syn::Lit::Str(ref s) = pair.lit { + syntax = Some(s.value()) + } else { + panic!("syntax value 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"); - }, + } attr => panic!("unsupported annotation key '{}' found", attr), } } diff --git a/askama_derive/src/lib.rs b/askama_derive/src/lib.rs index f578d80..5c84004 100644 --- a/askama_derive/src/lib.rs +++ b/askama_derive/src/lib.rs @@ -189,7 +189,8 @@ impl<'a> Context<'a> { } else { unreachable!() } - }).collect(); + }) + .collect(); Context { nodes, |