diff options
author | 2024-02-11 21:46:57 -0800 | |
---|---|---|
committer | 2024-02-11 21:46:57 -0800 | |
commit | 365e377349b9b4fba2eeb3fbd77e9069b548d263 (patch) | |
tree | e120b436ba9a08896250c1f55177bb654152a651 /trakt-macros | |
parent | 4b7aba99ef08a8fd6a6dd84637b2764c5d63a581 (diff) | |
download | trakt-365e377349b9b4fba2eeb3fbd77e9069b548d263.tar.gz trakt-365e377349b9b4fba2eeb3fbd77e9069b548d263.tar.zst trakt-365e377349b9b4fba2eeb3fbd77e9069b548d263.zip |
Adjust deps and clippy
Diffstat (limited to 'trakt-macros')
-rw-r--r-- | trakt-macros/Cargo.toml | 2 | ||||
-rw-r--r-- | trakt-macros/src/lib.rs | 11 | ||||
-rw-r--r-- | trakt-macros/src/paginated.rs | 38 |
3 files changed, 32 insertions, 19 deletions
diff --git a/trakt-macros/Cargo.toml b/trakt-macros/Cargo.toml index 98988cf..59df0f7 100644 --- a/trakt-macros/Cargo.toml +++ b/trakt-macros/Cargo.toml @@ -9,6 +9,6 @@ proc-macro = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -proc-macro2 = "1.0.78" +proc-macro2 = "1" quote = "1" syn = { version = "2", features = ["full"] } diff --git a/trakt-macros/src/lib.rs b/trakt-macros/src/lib.rs index 5dcb4e7..6eddfc0 100644 --- a/trakt-macros/src/lib.rs +++ b/trakt-macros/src/lib.rs @@ -1,3 +1,14 @@ +#![warn( + clippy::pedantic, + clippy::nursery, + clippy::as_underscore, + clippy::clone_on_ref_ptr, + clippy::format_push_string, + clippy::mod_module_files, + clippy::str_to_string +)] +#![allow(clippy::module_name_repetitions)] + mod paginated; mod request; diff --git a/trakt-macros/src/paginated.rs b/trakt-macros/src/paginated.rs index d9aa2fd..d2cc8b5 100644 --- a/trakt-macros/src/paginated.rs +++ b/trakt-macros/src/paginated.rs @@ -78,14 +78,15 @@ fn handle_field_attrs(input: &DeriveInput) -> syn::Result<&syn::Field> { } } - if let Some(ret) = ret { - Ok(ret) - } else { - Err(syn::Error::new( - Span::call_site(), - "missing #[trakt(pagination)] attribute", - )) - } + ret.map_or_else( + || { + Err(syn::Error::new( + Span::call_site(), + "missing #[trakt(pagination)] attribute", + )) + }, + Ok, + ) } /// Extracts the inner type of `PaginationResponse<T>` type. @@ -119,17 +120,18 @@ fn extract_item(tp: &syn::Type) -> syn::Result<&syn::Type> { if let syn::GenericArgument::Type(t) = &args[0] { tp = Some(t); break; - } else { - return Err(syn::Error::new(args.span(), "expected a type argument")); } - } - if let Some(tp) = tp { - Ok(tp) - } else { - Err(syn::Error::new( - tp.span(), - "expected a PaginationResponse type", - )) + return Err(syn::Error::new(args.span(), "expected a type argument")); } + + tp.map_or_else( + || { + Err(syn::Error::new( + tp.span(), + "expected a PaginationResponse type", + )) + }, + Ok, + ) } |