Format code with cargo fmt

This commit is contained in:
Rodolphe Breard 2019-01-18 19:10:12 +01:00
parent 8173cb282a
commit 22c376930b
4 changed files with 20 additions and 13 deletions

View file

@ -9,8 +9,8 @@
extern crate proc_macro; extern crate proc_macro;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use syn::{parse_macro_input, ItemFn};
use quote::quote; use quote::quote;
use syn::{parse_macro_input, ItemFn};
fn get_type( fn get_type(
params: &syn::punctuated::Punctuated<syn::FnArg, syn::token::Comma>, params: &syn::punctuated::Punctuated<syn::FnArg, syn::token::Comma>,
@ -23,7 +23,7 @@ fn get_type(
}, },
})); }));
let cb = syn::Type::Verbatim(syn::TypeVerbatim { let cb = syn::Type::Verbatim(syn::TypeVerbatim {
tts: quote!{ opensmtpd::Callback::NoCtx }, tts: quote! { opensmtpd::Callback::NoCtx },
}); });
Ok((ctx, cb)) Ok((ctx, cb))
} }
@ -32,10 +32,10 @@ fn get_type(
syn::Type::Reference(r) => { syn::Type::Reference(r) => {
let cb = match r.mutability { let cb = match r.mutability {
Some(_) => syn::Type::Verbatim(syn::TypeVerbatim { Some(_) => syn::Type::Verbatim(syn::TypeVerbatim {
tts: quote!{ opensmtpd::Callback::CtxMut }, tts: quote! { opensmtpd::Callback::CtxMut },
}), }),
None => syn::Type::Verbatim(syn::TypeVerbatim { None => syn::Type::Verbatim(syn::TypeVerbatim {
tts: quote!{ opensmtpd::Callback::Ctx }, tts: quote! { opensmtpd::Callback::Ctx },
}), }),
}; };
Ok((r.elem.clone(), cb)) Ok((r.elem.clone(), cb))

View file

@ -7,8 +7,10 @@
// except according to those terms. // except according to those terms.
use crate::errors::Error; use crate::errors::Error;
use nom::{alt, alt_complete, call, complete, cond, do_parse, error_position, map_res, named, opt, use nom::{
tag, take_until, take_while}; alt, alt_complete, call, complete, cond, do_parse, error_position, map_res, named, opt, tag,
take_until, take_while,
};
use std::str::FromStr; use std::str::FromStr;
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
@ -46,7 +48,8 @@ impl FromStr for Event {
type Err = Error; type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = s.to_lowercase() let s = s
.to_lowercase()
.replace("link", "link-") .replace("link", "link-")
.replace("tx", "tx-") .replace("tx", "tx-")
.replace("protocol", "protocol-") .replace("protocol", "protocol-")

View file

@ -35,9 +35,11 @@ fn get_events_from_string(event_str: &str) -> MatchEvent {
"Any" | "All" => { "Any" | "All" => {
return MatchEvent::All; return MatchEvent::All;
} }
_ => if let Ok(e) = Event::from_str(name) { _ => {
if let Ok(e) = Event::from_str(name) {
events.push(e); events.push(e);
}, }
}
} }
} }
MatchEvent::Evt(events) MatchEvent::Evt(events)

View file

@ -89,9 +89,11 @@ impl<T: Clone + Default + 'static> SmtpIn<T> {
let mut evts = Vec::new(); let mut evts = Vec::new();
for eh in self.event_handlers.iter() { for eh in self.event_handlers.iter() {
match eh.event { match eh.event {
MatchEvent::Evt(ref v) => for e in v.iter() { MatchEvent::Evt(ref v) => {
for e in v.iter() {
evts.push(e); evts.push(e);
}, }
}
MatchEvent::All => { MatchEvent::All => {
println!("register|report|smtp-in|*"); println!("register|report|smtp-in|*");
evts.clear(); evts.clear();