summaryrefslogtreecommitdiff
path: root/trakt-macros
diff options
context:
space:
mode:
Diffstat (limited to 'trakt-macros')
-rw-r--r--trakt-macros/Cargo.toml2
-rw-r--r--trakt-macros/src/lib.rs11
-rw-r--r--trakt-macros/src/paginated.rs38
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,
+ )
}