@@ -445,6 +445,22 @@ impl GenericArgs {
445445 }
446446 bug ! ( "GenericArgs::inputs: not a `Fn(T) -> U`" ) ;
447447 }
448+
449+ pub fn own_counts ( & self ) -> GenericParamCount {
450+ // We could cache this as a property of `GenericParamCount`, but
451+ // the aim is to refactor this away entirely eventually and the
452+ // presence of this method will be a constant reminder.
453+ let mut own_counts: GenericParamCount = Default :: default ( ) ;
454+
455+ for arg in & self . args {
456+ match arg {
457+ GenericArg :: Lifetime ( _) => own_counts. lifetimes += 1 ,
458+ GenericArg :: Type ( _) => own_counts. types += 1 ,
459+ } ;
460+ }
461+
462+ own_counts
463+ }
448464}
449465
450466/// A modifier on a bound, currently this is only used for `?Sized`, where the
@@ -503,6 +519,7 @@ pub struct GenericParam {
503519 pub kind : GenericParamKind ,
504520}
505521
522+ #[ derive( Default ) ]
506523pub struct GenericParamCount {
507524 pub lifetimes : usize ,
508525 pub types : usize ,
@@ -533,10 +550,7 @@ impl Generics {
533550 // We could cache this as a property of `GenericParamCount`, but
534551 // the aim is to refactor this away entirely eventually and the
535552 // presence of this method will be a constant reminder.
536- let mut own_counts = GenericParamCount {
537- lifetimes : 0 ,
538- types : 0 ,
539- } ;
553+ let mut own_counts: GenericParamCount = Default :: default ( ) ;
540554
541555 for param in & self . params {
542556 match param. kind {
0 commit comments