diff options
Diffstat (limited to 'src/transform.rs')
-rw-r--r-- | src/transform.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/transform.rs b/src/transform.rs index cbada94..c3116cf 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -1,13 +1,16 @@ use std::collections::HashMap; use proc_macro2::Span; -use syn::{spanned::Spanned, Generics, Ident, PathArguments, Type, TypeParamBound, TypePath}; +use syn::{ + spanned::Spanned, GenericArgument, Generics, Ident, PathArguments, Type, TypeParamBound, + TypePath, +}; use crate::{ parse_assoc_type::DestType, parse_trait_sig::{MethodParseError, TypeTransform}, syn_utils::{find_in_path, find_in_type}, - As, AssocTypeMatcher, + AssocTypeMatcher, }; #[derive(Default)] @@ -42,9 +45,10 @@ impl AssocTypeConversions<'_> { } else if ident == "Option" && path.segments.len() == 1 { let first_seg = path.segments.first_mut().unwrap(); - if let Some(args) = first_seg.arguments.get_as_mut() { + if let PathArguments::AngleBracketed(args) = &mut first_seg.arguments { if args.args.len() == 1 { - if let Some(generic_type) = args.args.first_mut().unwrap().get_as_mut() { + if let GenericArgument::Type(generic_type) = args.args.first_mut().unwrap() + { if find_in_type(generic_type, &AssocTypeMatcher).is_some() { return Ok(TypeTransform::Map( self.parse_type_path(generic_type)?.into(), @@ -55,13 +59,12 @@ impl AssocTypeConversions<'_> { } } else if ident == "Result" && path.segments.len() == 1 { let first_seg = path.segments.first_mut().unwrap(); - if let Some(args) = first_seg.arguments.get_as_mut() { + if let PathArguments::AngleBracketed(args) = &mut first_seg.arguments { if args.args.len() == 2 { let mut args_iter = args.args.iter_mut(); - if let (Some(ok_type), Some(err_type)) = ( - args_iter.next().unwrap().get_as_mut(), - args_iter.next().unwrap().get_as_mut(), - ) { + 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() { @@ -77,9 +80,10 @@ impl AssocTypeConversions<'_> { let last_seg = &path.segments.last().unwrap(); if last_seg.ident == "Result" { let last_seg = path.segments.last_mut().unwrap(); - if let Some(args) = last_seg.arguments.get_as_mut() { + if let PathArguments::AngleBracketed(args) = &mut last_seg.arguments { if args.args.len() == 1 { - if let Some(generic_type) = args.args.first_mut().unwrap().get_as_mut() + if let GenericArgument::Type(generic_type) = + args.args.first_mut().unwrap() { if find_in_type(generic_type, &AssocTypeMatcher).is_some() { return Ok(TypeTransform::Map( |