swiftlang/swift

[SR-3419] Strides should be collections

開放

#46,007 建立於 2016年12月14日

 (0 則留言) (0 個反應) (0 位負責人)Swift (10,719 個分叉)batch import
affects ABIgood first issueimprovementstandard libraryswift evolution proposal needed

倉庫指標

星標
 (69,989 顆星)
PR 合併指標
 (平均合併 8天 17小時) (30 天內合併 510 個 PR)

描述

Previous ID SR-3419
Radar rdar://problem/17816925
Original Reporter @airspeedswift
Type Improvement
Votes 0
Component/s Standard Library
Labels Improvement, AffectsABI, StarterProposal, swift-evolution-proposal-needed
Assignee None
Priority Medium

md5: 20684cd6a789b38a9426158bdf2d0b60

Issue Description:

In Swift 3.0, StrideTo and StrideThrough conform to Sequence, but not Collection.

While they can't be bi-directional or random-access, as the last (or abitrary) element can't necessarily be reached in O( n ) for all strideable types, it should be possible to make them forward-only collections. One straightforward implementation would be to make the index each value zipped with a count (for Comparable purposes).

Once we have conditional conformance, it should be possible to make specific strides (e.g. ones over integers) conform to random access.

貢獻者指南