1 use proc_macro2::{Punct, Spacing, TokenStream}; 2 3 // None of our generated code requires the `From::from` error conversion 4 // performed by the standard library's `try!` macro. With this simplified macro 5 // we see a significant improvement in type checking and borrow checking time of 6 // the generated code and a slight improvement in binary size. replacement() -> TokenStream7pub fn replacement() -> TokenStream { 8 // Cannot pass `$expr` to `quote!` prior to Rust 1.17.0 so interpolate it. 9 let dollar = Punct::new('$', Spacing::Alone); 10 11 quote! { 12 #[allow(unused_macros)] 13 macro_rules! try { 14 (#dollar __expr:expr) => { 15 match #dollar __expr { 16 _serde::__private::Ok(__val) => __val, 17 _serde::__private::Err(__err) => { 18 return _serde::__private::Err(__err); 19 } 20 } 21 } 22 } 23 } 24 } 25