@@ -36,6 +36,10 @@ use syn::Item;
3636/// Marks a `struct` as a router or marks an `impl` block as a router
3737/// implementation
3838///
39+ /// # Panics
40+ ///
41+ /// Panics if used on an item that is not a `struct` or `impl` block.
42+ ///
3943/// # Examples
4044///
4145/// ```rust
@@ -57,17 +61,19 @@ use syn::Item;
5761/// ```
5862#[ proc_macro_attribute]
5963pub fn router ( arguments : TokenStream , item : TokenStream ) -> TokenStream {
60- let output = match syn:: parse :: < Item > ( item. clone ( ) ) {
64+ match syn:: parse :: < Item > ( item) {
6165 Ok ( Item :: Struct ( item) ) => implementations:: fields ( arguments, item) ,
6266 Ok ( Item :: Impl ( item) ) => implementations:: methods ( arguments, item) ,
6367 _ => panic ! ( "`#[rossweisse::router]` can only be used on `struct`s" ) ,
64- } ;
65-
66- output. into ( )
68+ }
6769}
6870
6971/// Marks a method of a router implementation as a route to mount
7072///
73+ /// # Panics
74+ ///
75+ /// Panics if used on an item that is not a function.
76+ ///
7177/// # Examples
7278///
7379/// ```rust
@@ -84,10 +90,8 @@ pub fn router(arguments: TokenStream, item: TokenStream) -> TokenStream {
8490/// ```
8591#[ proc_macro_attribute]
8692pub fn route ( arguments : TokenStream , item : TokenStream ) -> TokenStream {
87- let output = match syn:: parse :: < Item > ( item. clone ( ) ) {
88- Ok ( Item :: Fn ( item) ) => implementations:: route ( arguments, item) ,
93+ match syn:: parse :: < Item > ( item) {
94+ Ok ( Item :: Fn ( ref item) ) => implementations:: route ( arguments, item) ,
8995 _ => panic ! ( "`#[rossweisse::route]` can only be used on `fn`s" ) ,
90- } ;
91-
92- output. into ( )
96+ }
9397}
0 commit comments