castFrom<S, T> static method Null safety

Iterable<T> castFrom<S, T>(
  1. Iterable<S> source
)

Adapts source to be an Iterable<T>.

Any time the iterable would produce an element that is not a T, the element access will throw. If all elements of source are actually instances of T, or if only elements that are actually instances of T are accessed, then the resulting iterable can be used as an Iterable<T>.

Implementation

static Iterable<T> castFrom<S, T>(Iterable<S> source) =>
    CastIterable<S, T>(source);