diff --git a/crates/cgp-macro-lib/src/cgp_fn/attributes.rs b/crates/cgp-macro-lib/src/cgp_fn/attributes.rs index 433edc08..3a7653a5 100644 --- a/crates/cgp-macro-lib/src/cgp_fn/attributes.rs +++ b/crates/cgp-macro-lib/src/cgp_fn/attributes.rs @@ -1,5 +1,3 @@ -use core::mem; - use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{Attribute, TypeParamBound, WherePredicate}; @@ -9,13 +7,12 @@ use crate::cgp_impl::UseProviderSpec; use crate::parse::SimpleType; pub fn parse_function_attributes( - attributes: &mut Vec, -) -> syn::Result { + attributes: Vec, +) -> syn::Result<(FunctionAttributes, Vec)> { let mut parsed_attributes = FunctionAttributes::default(); + let mut rest_attributes = Vec::new(); - let in_attributes = mem::take(attributes); - - for attribute in in_attributes.into_iter() { + for attribute in attributes.into_iter() { if let Some(ident) = attribute.path().get_ident() { if ident == "extend" { let extend_bound = attribute @@ -38,12 +35,12 @@ pub fn parse_function_attributes( .parse_args_with(Punctuated::::parse_terminated)?; parsed_attributes.use_provider.extend(use_provider); } else { - attributes.push(attribute); + rest_attributes.push(attribute); } } else { - attributes.push(attribute); + rest_attributes.push(attribute); } } - Ok(parsed_attributes) + Ok((parsed_attributes, rest_attributes)) } diff --git a/crates/cgp-macro-lib/src/cgp_fn/derive.rs b/crates/cgp-macro-lib/src/cgp_fn/derive.rs index 14c1dd3f..6850c04f 100644 --- a/crates/cgp-macro-lib/src/cgp_fn/derive.rs +++ b/crates/cgp-macro-lib/src/cgp_fn/derive.rs @@ -15,15 +15,17 @@ pub fn derive_cgp_fn(trait_ident: &Ident, mut item_fn: ItemFn) -> syn::Result syn::Result String { + format!("Hello, {}!", name) +} diff --git a/crates/cgp-tests/tests/cgp_fn_tests/mod.rs b/crates/cgp-tests/tests/cgp_fn_tests/mod.rs index 5db1140a..829f72ac 100644 --- a/crates/cgp-tests/tests/cgp_fn_tests/mod.rs +++ b/crates/cgp-tests/tests/cgp_fn_tests/mod.rs @@ -1,3 +1,4 @@ +pub mod r#async; pub mod basic; pub mod call; pub mod extend; diff --git a/crates/cgp-tests/tests/cgp_fn_tests/multi.rs b/crates/cgp-tests/tests/cgp_fn_tests/multi.rs index 758186c5..5c93b406 100644 --- a/crates/cgp-tests/tests/cgp_fn_tests/multi.rs +++ b/crates/cgp-tests/tests/cgp_fn_tests/multi.rs @@ -12,10 +12,11 @@ pub trait HasBarType { type Baz; } -#[allow(unused)] #[cgp_fn] +#[allow(unused)] +#[async_trait] #[use_type(>::{Foo as FooX}, >::{Foo as FooY}, HasBarType::{Bar, Baz})] -pub fn do_foo_bar( +pub async fn do_foo_bar( &self, x: X, #[implicit] foo_x: &FooX,