More efficient try!() alternative

This commit is contained in:
David Tolnay
2018-04-21 10:51:32 -07:00
parent 382f3c2771
commit 6a8c39b2aa
4 changed files with 32 additions and 0 deletions
+3
View File
@@ -15,6 +15,7 @@ use bound;
use fragment::{Fragment, Match, Stmts};
use internals::ast::{Container, Data, Field, Style, Variant};
use internals::{attr, Ctxt};
use try;
use std::u32;
@@ -55,10 +56,12 @@ pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<Tokens, Strin
}
};
let try_replacement = try::replacement();
let generated = quote! {
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const #dummy_const: () = {
extern crate serde as _serde;
#try_replacement
#impl_block
};
};