@@ -17,14 +17,15 @@ use syn::{
1717/// methods that are inherently implemented this is methods that have a pub
1818/// visibility keyword. For methods that are implementing a trait the pub is
1919/// assumed and so all methods are returned.
20- pub fn impl_pub_methods ( imp : & ItemImpl ) -> impl Iterator < Item = & ImplItemFn > {
20+ pub fn impl_pub_methods ( imp : & ItemImpl ) -> Vec < ImplItemFn > {
2121 imp. items
2222 . iter ( )
2323 . filter_map ( |i| match i {
24- ImplItem :: Fn ( m) => Some ( m) ,
24+ ImplItem :: Fn ( m) => Some ( m. clone ( ) ) ,
2525 _ => None ,
2626 } )
2727 . filter ( |m| imp. trait_ . is_some ( ) || matches ! ( m. vis, Visibility :: Public ( _) ) )
28+ . collect ( )
2829}
2930
3031/// Gets methods from the trait.
@@ -161,22 +162,23 @@ impl HasFnsItem {
161162 }
162163 }
163164
164- pub fn fns ( & self ) -> Vec < Fn < ' _ > > {
165+ pub fn fns ( & self ) -> Vec < Fn > {
165166 match self {
166167 HasFnsItem :: Trait ( t) => trait_methods ( t)
167168 . map ( |m| Fn {
168- ident : & m. sig . ident ,
169- attrs : & m. attrs ,
170- inputs : & m. sig . inputs ,
171- output : & m. sig . output ,
169+ ident : m. sig . ident . clone ( ) ,
170+ attrs : m. attrs . clone ( ) ,
171+ inputs : m. sig . inputs . clone ( ) ,
172+ output : m. sig . output . clone ( ) ,
172173 } )
173174 . collect ( ) ,
174175 HasFnsItem :: Impl ( i) => impl_pub_methods ( i)
176+ . iter ( )
175177 . map ( |m| Fn {
176- ident : & m. sig . ident ,
177- attrs : & m. attrs ,
178- inputs : & m. sig . inputs ,
179- output : & m. sig . output ,
178+ ident : m. sig . ident . clone ( ) ,
179+ attrs : m. attrs . clone ( ) ,
180+ inputs : m. sig . inputs . clone ( ) ,
181+ output : m. sig . output . clone ( ) ,
180182 } )
181183 . collect ( ) ,
182184 }
@@ -210,16 +212,16 @@ impl ToTokens for HasFnsItem {
210212 }
211213}
212214
213- pub struct Fn < ' a > {
214- pub ident : & ' a Ident ,
215- pub attrs : & ' a [ Attribute ] ,
216- pub inputs : & ' a Punctuated < FnArg , Comma > ,
217- pub output : & ' a ReturnType ,
215+ pub struct Fn {
216+ pub ident : Ident ,
217+ pub attrs : Vec < Attribute > ,
218+ pub inputs : Punctuated < FnArg , Comma > ,
219+ pub output : ReturnType ,
218220}
219221
220- impl < ' a > Fn < ' a > {
222+ impl Fn {
221223 pub fn output ( & self ) -> Type {
222- let t = match self . output {
224+ let t = match & self . output {
223225 ReturnType :: Default => quote ! ( ( ) ) ,
224226 ReturnType :: Type ( _, typ) => match unpack_result ( typ) {
225227 Some ( ( t, _) ) => quote ! ( #t) ,
@@ -229,7 +231,7 @@ impl<'a> Fn<'a> {
229231 Type :: Verbatim ( t)
230232 }
231233 pub fn try_output ( & self , crate_path : & Path ) -> Type {
232- let ( t, e) = match self . output {
234+ let ( t, e) = match & self . output {
233235 ReturnType :: Default => ( quote ! ( ( ) ) , quote ! ( #crate_path:: Error ) ) ,
234236 ReturnType :: Type ( _, typ) => match unpack_result ( typ) {
235237 Some ( ( t, e) ) => ( quote ! ( #t) , quote ! ( #e) ) ,
0 commit comments