From 43fb2c613448589e0bac61996f38653cbefebd45 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 21 Jan 2026 09:03:05 +0000 Subject: fix(rossweisse): Fix all clippy pedantic and nursery lint errors --- rossweisse/src/lib.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'rossweisse/src/lib.rs') diff --git a/rossweisse/src/lib.rs b/rossweisse/src/lib.rs index 612bbac..815f36d 100644 --- a/rossweisse/src/lib.rs +++ b/rossweisse/src/lib.rs @@ -36,6 +36,10 @@ use syn::Item; /// Marks a `struct` as a router or marks an `impl` block as a router /// implementation /// +/// # Panics +/// +/// Panics if used on an item that is not a `struct` or `impl` block. +/// /// # Examples /// /// ```rust @@ -57,17 +61,19 @@ use syn::Item; /// ``` #[proc_macro_attribute] pub fn router(arguments: TokenStream, item: TokenStream) -> TokenStream { - let output = match syn::parse::(item.clone()) { + match syn::parse::(item) { Ok(Item::Struct(item)) => implementations::fields(arguments, item), Ok(Item::Impl(item)) => implementations::methods(arguments, item), _ => panic!("`#[rossweisse::router]` can only be used on `struct`s"), - }; - - output.into() + } } /// Marks a method of a router implementation as a route to mount /// +/// # Panics +/// +/// Panics if used on an item that is not a function. +/// /// # Examples /// /// ```rust @@ -84,10 +90,8 @@ pub fn router(arguments: TokenStream, item: TokenStream) -> TokenStream { /// ``` #[proc_macro_attribute] pub fn route(arguments: TokenStream, item: TokenStream) -> TokenStream { - let output = match syn::parse::(item.clone()) { - Ok(Item::Fn(item)) => implementations::route(arguments, item), + match syn::parse::(item) { + Ok(Item::Fn(ref item)) => implementations::route(arguments, item), _ => panic!("`#[rossweisse::route]` can only be used on `fn`s"), - }; - - output.into() + } } -- cgit v1.2.3