You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0447-span-access-shared-contiguous-storage.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ extension Span where Element: ~Copyable {
114
114
publicvar count: Int { get }
115
115
116
116
/// A Boolean value indicating whether the span is empty.
117
-
publicvar isEmpty: Bool { get }
117
+
publicvar isEmpty: Bool { get }
118
118
119
119
/// The type that represents a position in `Span`.
120
120
publictypealiasIndex=Int
@@ -146,7 +146,7 @@ extension Span where Element: ~Copyable {
146
146
}
147
147
```
148
148
149
-
When using the unchecked subscript, the index must be known to be valid. While we are not proposing explicit index validation API on `Span` itself, its `indices` property can be use to validate a single index, in the form of the function `Range<Int>.contains(_: Int) -> Bool`. We expect that `Range`will also add efficient containment checking of a subrange's endpoints, which should be generally useful for index range validation in this and other contexts.
149
+
When using the unchecked subscript, the index must be known to be valid. While we are not proposing explicit index validation API on `Span` itself, its `indices` property can be use to validate a single index, in the form of the function `Range<Int>.contains(_: Int) -> Bool`. We expect that `Range`will also add efficient containment checking of a subrange's endpoints, which should be generally useful for index range validation in this and other contexts.
150
150
151
151
##### Identifying whether a `Span` is a subrange of another:
152
152
@@ -468,7 +468,7 @@ Of these, the closure-taking functions can be implemented now, but it is unclear
468
468
469
469
#### Index Validation Utilities
470
470
471
-
This proposal originally included index validation utilities for `Span`. such as `boundsContain(_: Index) ->Bool` and `boundsContain(_: Range<Index>) ->Bool`. After review feedback, we believe that the utilities proposed would also be useful for index validation on `UnsafeBufferPointer`, `Array`, and other similar `RandomAccessCollection`types. `Range` already a single-element `contains(_: Bound) ->Bool` function which can be made even more efficient. We should add an additional function that identifies whether a `Range`contains the _endpoints_ ofanother `Range`. Note that this is not the same as the existing `contains(_: some Collection<Bound>) ->Bool`,which is about the _elements_ ofthe collection. This semantic difference can lead to different results when examing empty `Range`instances.
471
+
This proposal originally included index validation utilities for `Span`. such as `boundsContain(_: Index) ->Bool` and `boundsContain(_: Range<Index>) ->Bool`. After review feedback, we believe that the utilities proposed would also be useful for index validation on `UnsafeBufferPointer`, `Array`, and other similar `RandomAccessCollection`types. `Range` already a single-element `contains(_: Bound) ->Bool` function which can be made even more efficient. We should add an additional function that identifies whether a `Range`contains the _endpoints_ ofanother `Range`. Note that this is not the same as the existing `contains(_: some Collection<Bound>) ->Bool`,which is about the _elements_ ofthe collection. This semantic difference can lead to different results when examing empty `Range`instances.
0 commit comments