aboutsummaryrefslogtreecommitdiff
path: root/src/parse_assoc_type.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse_assoc_type.rs')
-rw-r--r--src/parse_assoc_type.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/parse_assoc_type.rs b/src/parse_assoc_type.rs
index 85f3723..048e58c 100644
--- a/src/parse_assoc_type.rs
+++ b/src/parse_assoc_type.rs
@@ -1,7 +1,7 @@
-use proc_macro2::Span;
+use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::spanned::Spanned;
-use syn::{GenericArgument, Ident, Path, PathArguments, PathSegment, TraitItemType, Type};
+use syn::{GenericArgument, Ident, PathArguments, PathSegment, TraitItemType, Type};
use crate::match_assoc_type;
use crate::parse_trait_sig::TypeTransform;
@@ -16,16 +16,16 @@ pub enum AssocTypeParseError {
#[derive(Debug, Clone)]
pub struct BoxType {
- trait_name: Path,
- placeholder_lifetime: bool,
+ pub inner: TokenStream,
+ pub placeholder_lifetime: bool,
}
impl ToTokens for BoxType {
fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
- let path = &self.trait_name;
+ let inner = &self.inner;
match self.placeholder_lifetime {
- true => tokens.extend(quote! {Box<dyn #path + '_>}),
- false => tokens.extend(quote! {Box<dyn #path>}),
+ true => tokens.extend(quote! {Box<#inner + '_>}),
+ false => tokens.extend(quote! {Box<#inner>}),
}
}
}
@@ -79,10 +79,11 @@ pub fn parse_assoc_type(
}
}
}
+ let path = &bound.path;
return Ok((
&assoc_type.ident,
DestType::Box(BoxType {
- trait_name: bound.path.clone(),
+ inner: quote! {dyn #path},
placeholder_lifetime: !lifetime_bounds(&assoc_type.bounds)
.any(|l| l.ident == "static"),
}),