public static int Count <TSource>(this IEnumerable <TSource> source)
        {
            switch (source)
            {
            case TSource[] array:
                return(array.Length);

            case IReadOnlyCollection <TSource> collection:
                return(collection.Count);

            default:
                return(CountDowncasted <IEnumerable <TSource>, TSource> .Count(source));
            }
        }
 public static int Count <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate)
 => CountDowncasted <IEnumerable <TSource>, TSource> .Count(source, predicate);