in propfuzz-macro/src/propfuzz_impl.rs [39:94]
fn new(attr: &'a [NestedMeta], item: &'a ItemFn) -> Result<Self> {
let mut errors = ErrorList::new();
let mut config_builder = PropfuzzConfigBuilder::default();
// Apply the arguments from the first #[propfuzz] invocation.
config_builder.apply_args(attr, &mut errors);
let name = &item.sig.ident;
// Read the description from the doc comment.
let description = {
let description = item
.attrs
.iter()
.filter_map(|attr| {
if attr.path.is_ident("doc") {
Some(extract_doc_comment(attr))
} else {
None
}
})
.collect::<Result<Vec<_>>>()?;
if description.is_empty() {
None
} else {
Some(description.join("\n"))
}
};
// Read arguments from remaining #[propfuzz] attributes.
let (propfuzz_attrs, other_attrs) = item
.attrs
.iter()
.partition::<Vec<_>, _>(|attr| attr.path.is_ident("propfuzz"));
config_builder.apply_attrs(propfuzz_attrs, &mut errors);
let body = match PropfuzzFnBody::new(&item.sig, &item.block) {
Ok(body) => body,
Err(error) => return Err(errors.combine_finish(error)),
};
let struct_name = format_ident!("{}{}", Self::STRUCT_PREFIX, name);
// If any errors were collected, return them.
errors.finish()?;
Ok(Self {
name: &item.sig.ident,
description,
other_attrs,
config: config_builder.finish(),
struct_name,
body,
})
}