Skip to content

Commit 2e1da48

Browse files
authored
Merge pull request #58544 from lorentey/bidirectional-docs-5.7
[5.7][stdlib][docs] Clarify BidirectionalCollection requirements
2 parents 3eaed12 + 3867774 commit 2e1da48

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stdlib/public/core/BidirectionalCollection.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
/// `Collection` protocol.
2929
///
3030
/// Indices that are moved forward and backward in a bidirectional collection
31-
/// move by the same amount in each direction. That is, for any index `i` into
32-
/// a bidirectional collection `c`:
31+
/// move by the same amount in each direction. That is, for any valid index `i`
32+
/// into a bidirectional collection `c`:
3333
///
3434
/// - If `i >= c.startIndex && i < c.endIndex`, then
3535
/// `c.index(before: c.index(after: i)) == i`.
3636
/// - If `i > c.startIndex && i <= c.endIndex`, then
3737
/// `c.index(after: c.index(before: i)) == i`.
38+
///
39+
/// Valid indices are exactly those indices that are reachable from the
40+
/// collection's `startIndex` by repeated applications of `index(after:)`, up
41+
/// to, and including, the `endIndex`.
3842
public protocol BidirectionalCollection: Collection
3943
where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection {
4044
// FIXME: Only needed for associated type inference.

0 commit comments

Comments
 (0)