@@ -61,6 +61,8 @@ pub trait StrExt: AsRef<str> {
61
61
62
62
#[ derive( Debug ) ]
63
63
pub enum TypeIdentResult < ' a > {
64
+ /// We bailed on detecting wrapper
65
+ Complex ( Box < TypeIdentResult < ' a > > ) ,
64
66
Ident ( & ' a Ident ) ,
65
67
Vec ( Box < TypeIdentResult < ' a > > ) ,
66
68
Box ( Box < TypeIdentResult < ' a > > ) ,
@@ -81,16 +83,22 @@ impl<'a> TypeIdentResult<'a> {
81
83
Self :: Option ( Box :: new ( inner) )
82
84
}
83
85
86
+ fn complex ( inner : Self ) -> Self {
87
+ Self :: Complex ( Box :: new ( inner) )
88
+ }
89
+
84
90
fn reference ( inner : Self ) -> Self {
85
91
Self :: Reference ( Box :: new ( inner) )
86
92
}
87
93
88
94
pub fn inner_ident ( & self ) -> & ' a Ident {
89
95
match self {
90
96
Self :: Ident ( it) => it,
91
- Self :: Vec ( it) | Self :: Box ( it) | Self :: Option ( it) | Self :: Reference ( it) => {
92
- it. inner_ident ( )
93
- }
97
+ Self :: Complex ( it)
98
+ | Self :: Vec ( it)
99
+ | Self :: Box ( it)
100
+ | Self :: Option ( it)
101
+ | Self :: Reference ( it) => it. inner_ident ( ) ,
94
102
}
95
103
}
96
104
@@ -116,6 +124,8 @@ pub enum TypeWrapper {
116
124
OptBox ,
117
125
OptVec ,
118
126
Ref ,
127
+ /// We bailed on detecting the type wrapper
128
+ Complex ,
119
129
}
120
130
121
131
#[ derive( Debug ) ]
@@ -151,7 +161,7 @@ impl TypeExt for Type {
151
161
if seg1. ident == "Option" {
152
162
TypeIdentResult :: option ( inner)
153
163
} else {
154
- inner
164
+ TypeIdentResult :: complex ( inner)
155
165
}
156
166
}
157
167
Some ( GenericArgument :: Lifetime ( _) ) => {
@@ -176,6 +186,11 @@ impl TypeExt for Type {
176
186
let mut wrapper = TypeWrapper :: None ;
177
187
let ident = match res {
178
188
TypeIdentResult :: Ident ( inner) => inner,
189
+ TypeIdentResult :: Complex ( inner) => {
190
+ wrapper = TypeWrapper :: Complex ;
191
+ let ( inner, _) = analyze ( inner) ?;
192
+ inner
193
+ }
179
194
TypeIdentResult :: Box ( inner) => {
180
195
wrapper = TypeWrapper :: Box ;
181
196
let ( inner, inner_kind) = analyze ( inner) ?;
0 commit comments