| 8 | use synstructure::{AddBounds, decl_derive}; |
| 9 | |
| 10 | fn find_collect_meta(attrs: &[syn::Attribute]) -> syn::Result<Option<&syn::Attribute>> { |
| 11 | let mut found = None; |
| 12 | for attr in attrs { |
| 13 | if attr.path().is_ident("collect") && found.replace(attr).is_some() { |
| 14 | return Err(syn::parse::Error::new_spanned( |
| 15 | attr.path(), |
| 16 | "Cannot specify multiple `#[collect]` attributes! Consider merging them.", |
| 17 | )); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | Ok(found) |
| 22 | } |
| 23 | |
| 24 | fn usage_error(meta: &syn::meta::ParseNestedMeta, msg: &str) -> syn::parse::Error { |
| 25 | meta.error(format_args!("{msg}. `#[collect(...)]` requires one mode (`require_static`, `no_drop`, or `unsafe_drop`) and optionally `bound = \"...\"`.")) |