File tree 2 files changed +13
-0
lines changed
Tests/SwiftAlgorithmsTests
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public struct AdjacentPairsSequence<Base: Sequence> {
69
69
}
70
70
71
71
extension AdjacentPairsSequence {
72
+ /// The iterator for an `AdjacentPairsSequence` or `AdjacentPairsCollection`.
72
73
public struct Iterator {
73
74
@usableFromInline
74
75
internal var base : Base . Iterator
@@ -113,6 +114,9 @@ extension AdjacentPairsSequence: Sequence {
113
114
}
114
115
}
115
116
117
+ extension AdjacentPairsSequence : LazySequenceProtocol
118
+ where Base: LazySequenceProtocol { }
119
+
116
120
/// A collection of adjacent pairs of elements built from an underlying
117
121
/// collection.
118
122
///
@@ -159,6 +163,7 @@ extension AdjacentPairsCollection {
159
163
}
160
164
161
165
extension AdjacentPairsCollection {
166
+ /// A position in an `AdjacentPairsCollection`.
162
167
public struct Index : Comparable {
163
168
@usableFromInline
164
169
internal var first : Base . Index
@@ -299,6 +304,9 @@ extension AdjacentPairsCollection: BidirectionalCollection
299
304
extension AdjacentPairsCollection : RandomAccessCollection
300
305
where Base: RandomAccessCollection { }
301
306
307
+ extension AdjacentPairsCollection : LazySequenceProtocol , LazyCollectionProtocol
308
+ where Base: LazyCollectionProtocol { }
309
+
302
310
extension AdjacentPairsCollection . Index : Hashable where Base. Index: Hashable {
303
311
@inlinable
304
312
public func hash( into hasher: inout Hasher ) {
Original file line number Diff line number Diff line change @@ -72,4 +72,9 @@ final class AdjacentPairsTests: XCTestCase {
72
72
func testIndexTraversals( ) {
73
73
validateIndexTraversals ( ( 1 ... 5 ) . adjacentPairs ( ) )
74
74
}
75
+
76
+ func testLaziness( ) {
77
+ XCTAssertLazySequence ( ( 0 ... ) . lazy. adjacentPairs ( ) )
78
+ XCTAssertLazyCollection ( ( 0 ..< 100 ) . lazy. adjacentPairs ( ) )
79
+ }
75
80
}
You can’t perform that action at this time.
0 commit comments