docs: @SuppressWarnings("unchecked")
    public static <T> T[] toArray(Iterable<? extends T> iterable, Class<T> type) {
      Collection<T> collection;
      if (iterable instanceof Collection) {
        collection = (Collection<T>) iterable;
      } else {
        collection = new ArrayList<T>();
        for (T element : iterable) {
          collection.add(element);
        }
      }
      T[] array = (T[]) Array.newInstance(type, collection.size());
      return collection.toArray(array);
    }