[swift-evolution] [Pitch] Remove destructive consumption from Sequence
Anton Zhilin
antonyzhilin at gmail.com
Thu Jun 23 16:04:44 CDT 2016
One practical implication of treating Sequence as infinite is in lazy
filter. If you pass Sequence, but not Collection, to lazy filter, it will
guarantee to iterate it only once. If it's a collection, it will feel free
to iterate it twice.
So one benefit of single-pass sequences is assumptions about behaviour of
an API: if it can work with sequences, then it will only iterate them
once.
More information about the swift-evolution
mailing list