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

View file

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

View file

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

View file

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