Skip to content

Commit 298f5d9

Browse files
committed
[stdlib] Add missing abstracts to a few types
1 parent b7432d8 commit 298f5d9

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

stdlib/public/core/Collection.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public protocol IndexableBase {
152152
func formIndex(after i: inout Index)
153153
}
154154

155+
/// A type that provides subscript access to its elements, with forward index
156+
/// traversal.
157+
///
158+
/// In most cases, it's best to ignore this protocol and use the `Collection`
159+
/// protocol instead, because it has a more complete interface.
155160
public protocol Indexable : IndexableBase {
156161
/// A type that can represent the number of steps between a pair of
157162
/// indices.

stdlib/public/core/FloatingPoint.swift.gyb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,13 @@ public protocol FloatingPoint: Comparable, IntegerLiteralConvertible,
488488
var isCanonical: Bool { get }
489489
}
490490

491+
/// The sign of a floating-point value.
491492
public enum FloatingPointSign: Int {
492493
case plus
493494
case minus
494495
}
495496

497+
/// The IEEE 754 floating-point classes.
496498
public enum FloatingPointClassification {
497499
case signalingNaN
498500
case quietNaN

stdlib/public/core/Index.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
/// This protocol is an implementation detail of `Integer`; do not use it
14+
/// directly.
1315
@_show_in_interface
1416
public protocol _Incrementable : Equatable {}
1517

stdlib/public/core/Indices.swift.gyb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
from gyb_stdlib_support import (
1515
TRAVERSALS,
1616
collectionForTraversal,
17-
defaultIndicesForTraversal
17+
defaultIndicesForTraversal,
18+
documentationNameForTraversal
1819
)
1920
}%
2021

2122
% for Traversal in TRAVERSALS:
2223
% Self = defaultIndicesForTraversal(Traversal)
24+
% collection = documentationNameForTraversal(Traversal)
2325

2426
// FIXME(ABI)(compiler limitation): There should be just one default
2527
// indices type that has conditional conformances to
2628
// `BidirectionalCollection` and `RandomAccessCollection`.
2729

30+
/// A collection of indices for an arbitrary ${collection}.
2831
public struct ${Self}<
2932
Elements : ${collectionForTraversal(Traversal).replace('Collection', 'Indexable')}
3033
// FIXME(ABI)(compiler limitation):

utils/gyb_stdlib_support.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ def defaultIndicesForTraversal(traversal): # noqa (N802)
4747
if traversal == 'RandomAccess':
4848
return 'DefaultRandomAccessIndices'
4949
assert False, 'unknown traversal'
50+
51+
52+
def documentationNameForTraversal(traversal):
53+
if traversal == 'Forward':
54+
return 'collection'
55+
if traversal == 'Bidirectional':
56+
return 'bidirectional collection'
57+
if traversal == 'RandomAccess':
58+
return 'random-access collection'
59+
assert False, 'unknown traversal'

0 commit comments

Comments
 (0)