aboutsummaryrefslogtreecommitdiff
path: root/src/parse_trait_sig.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse_trait_sig.rs')
-rw-r--r--src/parse_trait_sig.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/parse_trait_sig.rs b/src/parse_trait_sig.rs
index 4c0b4fd..8f578f7 100644
--- a/src/parse_trait_sig.rs
+++ b/src/parse_trait_sig.rs
@@ -9,7 +9,7 @@ use syn::{Ident, Signature, TypeImplTrait};
use crate::match_assoc_type;
use crate::parse_assoc_type::BoxType;
use crate::syn_utils::{iter_type, trait_bounds, TypeOrPath};
-use crate::transform::{dynamize_function_bounds, AssocTypeConversions, TransformError};
+use crate::transform::{dynamize_function_bounds, TransformError, TypeConverter};
#[derive(Debug, Clone)]
pub enum TypeTransform {
@@ -49,7 +49,7 @@ pub struct SignatureChanges {
pub fn parse_trait_signature(
signature: &mut Signature,
- assoc_type_conversions: &AssocTypeConversions,
+ type_converter: &TypeConverter,
) -> Result<SignatureChanges, (Span, MethodParseError)> {
if is_non_dispatchable(signature) {
return Err((signature.span(), MethodParseError::NonDispatchableMethod));
@@ -67,11 +67,10 @@ pub fn parse_trait_signature(
}
}
- let type_param_transforms =
- dynamize_function_bounds(&mut signature.generics, assoc_type_conversions)?;
+ let type_param_transforms = dynamize_function_bounds(&mut signature.generics, type_converter)?;
let return_type = match &mut signature.output {
- ReturnType::Type(_, og_type) => match assoc_type_conversions.parse_type_path(og_type) {
+ ReturnType::Type(_, og_type) => match type_converter.convert_type(og_type) {
Ok(ret_type) => ret_type,
Err(TransformError::UnconvertibleAssocType(span)) => {
return Err((span, MethodParseError::UnconvertibleAssocType));
@@ -147,7 +146,7 @@ mod tests {
parse_trait_sig::{
parse_trait_signature, MethodParseError, SignatureChanges, TypeTransform,
},
- transform::AssocTypeConversions,
+ transform::TypeConverter,
};
#[test]
@@ -173,14 +172,14 @@ mod tests {
})
.unwrap();
- let mut assoc_type_map = AssocTypeConversions::default();
+ let mut type_converter = TypeConverter::default();
let ident = format_ident!("A");
let dest_inner = Type::Verbatim(quote! {Example});
let dest = DestType::Into(&dest_inner);
- assoc_type_map.0.insert(ident, dest);
+ type_converter.assoc_type_conversions.insert(ident, dest);
assert!(matches!(
- parse_trait_signature(&mut type1.sig, &assoc_type_map),
+ parse_trait_signature(&mut type1.sig, &type_converter),
Ok(SignatureChanges {
return_type: TypeTransform::Into,
..