aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1a84a09..13cbce7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -71,6 +71,40 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
let mut type_converter = TypeConverter::default();
+ let mut blanket_impl_attrs = Vec::new();
+ let mut dyn_trait_attrs = Vec::new();
+
+ // FUTURE: use Vec::drain_filter once it's stable
+ let mut i = 0;
+ while i < original_trait.attrs.len() {
+ if original_trait.attrs[i].path.is_ident("blanket_impl_attr") {
+ let attr = original_trait.attrs.remove(i);
+ let group: Group = match syn::parse2(attr.tokens) {
+ Ok(g) => g,
+ Err(err) => {
+ return abort!(
+ err.span(),
+ "expected parenthesis: #[blanket_impl_attr(...)]"
+ )
+ }
+ };
+ let tokens = group.stream();
+ blanket_impl_attrs.push(quote! {#[#tokens]});
+ } else if original_trait.attrs[i].path.is_ident("dyn_trait_attr") {
+ let attr = original_trait.attrs.remove(i);
+ let group: Group = match syn::parse2(attr.tokens) {
+ Ok(g) => g,
+ Err(err) => {
+ return abort!(err.span(), "expected parenthesis: #[dyn_trait_attr(...)]")
+ }
+ };
+ let tokens = group.stream();
+ dyn_trait_attrs.push(quote! {#[#tokens]});
+ } else {
+ i += 1;
+ }
+ }
+
for item in &original_trait.items {
if let TraitItem::Type(assoc_type) = item {
match parse_assoc_type(assoc_type) {
@@ -146,40 +180,6 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
let mut method_impls: Vec<ImplItemMethod> = Vec::new();
- let mut blanket_impl_attrs = Vec::new();
- let mut dyn_trait_attrs = Vec::new();
-
- // FUTURE: use Vec::drain_filter once it's stable
- let mut i = 0;
- while i < original_trait.attrs.len() {
- if original_trait.attrs[i].path.is_ident("blanket_impl_attr") {
- let attr = original_trait.attrs.remove(i);
- let group: Group = match syn::parse2(attr.tokens) {
- Ok(g) => g,
- Err(err) => {
- return abort!(
- err.span(),
- "expected parenthesis: #[blanket_impl_attr(...)]"
- )
- }
- };
- let tokens = group.stream();
- blanket_impl_attrs.push(quote! {#[#tokens]});
- } else if original_trait.attrs[i].path.is_ident("dyn_trait_attr") {
- let attr = original_trait.attrs.remove(i);
- let group: Group = match syn::parse2(attr.tokens) {
- Ok(g) => g,
- Err(err) => {
- return abort!(err.span(), "expected parenthesis: #[dyn_trait_attr(...)]")
- }
- };
- let tokens = group.stream();
- dyn_trait_attrs.push(quote! {#[#tokens]});
- } else {
- i += 1;
- }
- }
-
let mut dyn_trait = ItemTrait {
ident: format_ident!("Dyn{}", original_trait.ident),