diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-20 12:29:15 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-20 12:29:28 +0100 |
commit | e918eb0ab2cf6d84751f5f52b49414d382b7abbb (patch) | |
tree | 0838bf246c8b8676985ecbdc6255b21fe619e12a /src/transform.rs | |
parent | 7d549f29d63df264884e80f1e95d881d7c0f7407 (diff) |
refactor: remove now pointless internal trait
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( |