swiftlang/swift

[SR-1959] Use Bounds.Stride for Index on countable ranges

Open

#44,568 创建于 2016年7月1日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Swift (69,989 star) (10,719 fork)batch import
affects ABIgood first issueimprovementstandard libraryswift evolution proposal needed

描述

Previous ID SR-1959
Radar rdar://problem/26302563
Original Reporter @gribozavr
Type Bug
Votes 0
Component/s Standard Library
Labels Bug, AffectsABI, StarterProposal, swift-evolution-proposal-needed
Assignee None
Priority Medium

md5: 6a8b1ccf3e51e9239df2d35454f79393

Issue Description:

CountableRange collection conformance defines an Index type that conforms to Strideable. That is not the case for the CountableClosedRange, which makes the two ranges not interchangeable in all cases.

ClosedRangeIndex implementation uses an internal enum that makes Strideable conformance hard to implement.

The proposed solution is to use Bounds.Stride as Index on both CountableRange and CountableClosedRange.

  • It is proposed to use `Bound.Stride` as index for both countable ranges.

  • The only problem with that is that `SubSequence` of a countable range can no longer be the same type (as indices will not be interchangeable). [Why is this? Someone needs to reconstruct the logic chain.]

  • But it can be solved by using one of the existing slice types for `SubSequence`.

NOTE: Requires a swift-evolution proposal.

贡献者指南

[SR-1959] Use Bounds.Stride for Index on countable ranges · swiftlang/swift#44568 | Good First Issue