MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / find_collect_meta

Function find_collect_meta

aiscript-derived/src/lib.rs:10–22  ·  view source on GitHub ↗
(attrs: &[syn::Attribute])

Source from the content-addressed store, hash-verified

8use synstructure::{AddBounds, decl_derive};
9
10fn 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
24fn 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 = \"...\"`."))

Callers 1

collect_deriveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected