aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/transform.rs b/src/transform.rs
index c3116cf..6640cf3 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -7,10 +7,10 @@ use syn::{
};
use crate::{
+ filter_map_assoc_paths, match_assoc_type,
parse_assoc_type::DestType,
parse_trait_sig::{MethodParseError, TypeTransform},
- syn_utils::{find_in_path, find_in_type},
- AssocTypeMatcher,
+ syn_utils::{iter_path, iter_type},
};
#[derive(Default)]
@@ -23,7 +23,7 @@ pub enum TransformError {
impl AssocTypeConversions<'_> {
pub fn parse_type_path(&self, type_: &mut Type) -> Result<TypeTransform, TransformError> {
- let assoc_span = match find_in_type(type_, &AssocTypeMatcher) {
+ let assoc_span = match iter_type(type_).filter_map(filter_map_assoc_paths).next() {
Some(path) => path.span(),
None => return Ok(TypeTransform::NoOp),
};
@@ -49,7 +49,7 @@ impl AssocTypeConversions<'_> {
if args.args.len() == 1 {
if let GenericArgument::Type(generic_type) = args.args.first_mut().unwrap()
{
- if find_in_type(generic_type, &AssocTypeMatcher).is_some() {
+ if iter_type(generic_type).any(match_assoc_type) {
return Ok(TypeTransform::Map(
self.parse_type_path(generic_type)?.into(),
));
@@ -65,8 +65,8 @@ impl AssocTypeConversions<'_> {
if let (GenericArgument::Type(ok_type), GenericArgument::Type(err_type)) =
(args_iter.next().unwrap(), args_iter.next().unwrap())
{
- if find_in_type(ok_type, &AssocTypeMatcher).is_some()
- || find_in_type(err_type, &AssocTypeMatcher).is_some()
+ if iter_type(ok_type).any(match_assoc_type)
+ || iter_type(err_type).any(match_assoc_type)
{
return Ok(TypeTransform::Result(
self.parse_type_path(ok_type)?.into(),
@@ -85,7 +85,7 @@ impl AssocTypeConversions<'_> {
if let GenericArgument::Type(generic_type) =
args.args.first_mut().unwrap()
{
- if find_in_type(generic_type, &AssocTypeMatcher).is_some() {
+ if iter_type(generic_type).any(match_assoc_type) {
return Ok(TypeTransform::Map(
self.parse_type_path(generic_type)?.into(),
));
@@ -146,7 +146,10 @@ pub fn dynamize_function_bounds(
}
}
}
- if let Some(path) = find_in_path(&bound.path, &AssocTypeMatcher) {
+ if let Some(path) = iter_path(&bound.path)
+ .filter_map(filter_map_assoc_paths)
+ .next()
+ {
return Err((
path.span(),
MethodParseError::UnconvertibleAssocTypeInTraitBound,