@@ -207,6 +207,7 @@ pub enum Type {
207
207
Fn ( Box < Type > , Box < Type > ) ,
208
208
/// Represents a future which promises to return the inner type.
209
209
Future ( Box < Type > ) ,
210
+ Dynamic ,
210
211
}
211
212
212
213
impl Default for Type {
@@ -258,6 +259,15 @@ impl Type {
258
259
_ => None ,
259
260
}
260
261
}
262
+ pub fn fn_fut_output ( & self ) -> Option < & Type > {
263
+ match self {
264
+ Type :: Fn ( _, second) => match second. as_ref ( ) {
265
+ Type :: Future ( fut) => Some ( fut) ,
266
+ _ => None ,
267
+ } ,
268
+ _ => None ,
269
+ }
270
+ }
261
271
262
272
pub fn function ( input : & Type , output : & Type ) -> Type {
263
273
Type :: Fn ( Box :: new ( input. clone ( ) ) , Box :: new ( output. clone ( ) ) )
@@ -281,6 +291,7 @@ impl Type {
281
291
Self :: Concrete ( ty) => Some ( ty. size ) ,
282
292
Self :: Fn ( _, _) => None ,
283
293
Self :: Future ( _) => None ,
294
+ Self :: Dynamic => None ,
284
295
}
285
296
}
286
297
@@ -290,6 +301,7 @@ impl Type {
290
301
Self :: Concrete ( ty) => Some ( ty. align ) ,
291
302
Self :: Fn ( _, _) => None ,
292
303
Self :: Future ( _) => None ,
304
+ Self :: Dynamic => None ,
293
305
}
294
306
}
295
307
@@ -299,6 +311,7 @@ impl Type {
299
311
Self :: Concrete ( _) => self ,
300
312
Self :: Fn ( _, output) => output. nested_type ( ) ,
301
313
Self :: Future ( output) => output. nested_type ( ) ,
314
+ Self :: Dynamic => self ,
302
315
}
303
316
}
304
317
}
@@ -320,6 +333,7 @@ impl core::fmt::Debug for Type {
320
333
Self :: Concrete ( arg0) => write ! ( f, "Concrete<{}>" , format_type( & arg0. name) ) ,
321
334
Self :: Fn ( arg0, arg1) => write ! ( f, "{arg0:?} → {arg1:?}" ) ,
322
335
Self :: Future ( arg0) => write ! ( f, "Future<{arg0:?}>" ) ,
336
+ Self :: Dynamic => write ! ( f, "Dynamic" ) ,
323
337
}
324
338
}
325
339
}
@@ -331,6 +345,7 @@ impl std::fmt::Display for Type {
331
345
Type :: Concrete ( ty) => write ! ( f, "{}" , format_type( & ty. name) ) ,
332
346
Type :: Fn ( input, output) => write ! ( f, "{input} → {output}" ) ,
333
347
Type :: Future ( ty) => write ! ( f, "Future<{ty}>" ) ,
348
+ Self :: Dynamic => write ! ( f, "Dynamic" ) ,
334
349
}
335
350
}
336
351
}
0 commit comments