aboutsummaryrefslogtreecommitdiff
path: root/rossweisse/src/lib.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-21 09:03:05 +0000
committerFuwn <[email protected]>2026-01-21 09:03:05 +0000
commit43fb2c613448589e0bac61996f38653cbefebd45 (patch)
tree8439711dcdca6227672a24538ee34fc0064e1c1a /rossweisse/src/lib.rs
parentperf(router): Reduce per-connection overhead with shared RequestHandler (diff)
downloadwindmark-43fb2c613448589e0bac61996f38653cbefebd45.tar.xz
windmark-43fb2c613448589e0bac61996f38653cbefebd45.zip
fix(rossweisse): Fix all clippy pedantic and nursery lint errors
Diffstat (limited to 'rossweisse/src/lib.rs')
-rw-r--r--rossweisse/src/lib.rs22
1 files changed, 13 insertions, 9 deletions
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>(item.clone()) {
+ match syn::parse::<Item>(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>(item.clone()) {
- Ok(Item::Fn(item)) => implementations::route(arguments, item),
+ match syn::parse::<Item>(item) {
+ Ok(Item::Fn(ref item)) => implementations::route(arguments, item),
_ => panic!("`#[rossweisse::route]` can only be used on `fn`s"),
- };
-
- output.into()
+ }
}