File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Tests/SwiftAlgorithmsTests Expand file tree Collapse file tree 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> {
6969}
7070
7171extension AdjacentPairsSequence {
72+ /// The iterator for an `AdjacentPairsSequence` or `AdjacentPairsCollection`.
7273 public struct Iterator {
7374 @usableFromInline
7475 internal var base : Base . Iterator
@@ -113,6 +114,9 @@ extension AdjacentPairsSequence: Sequence {
113114 }
114115}
115116
117+ extension AdjacentPairsSequence : LazySequenceProtocol
118+ where Base: LazySequenceProtocol { }
119+
116120/// A collection of adjacent pairs of elements built from an underlying
117121/// collection.
118122///
@@ -159,6 +163,7 @@ extension AdjacentPairsCollection {
159163}
160164
161165extension AdjacentPairsCollection {
166+ /// A position in an `AdjacentPairsCollection`.
162167 public struct Index : Comparable {
163168 @usableFromInline
164169 internal var first : Base . Index
@@ -299,6 +304,9 @@ extension AdjacentPairsCollection: BidirectionalCollection
299304extension AdjacentPairsCollection : RandomAccessCollection
300305 where Base: RandomAccessCollection { }
301306
307+ extension AdjacentPairsCollection : LazySequenceProtocol , LazyCollectionProtocol
308+ where Base: LazyCollectionProtocol { }
309+
302310extension AdjacentPairsCollection . Index : Hashable where Base. Index: Hashable {
303311 @inlinable
304312 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 {
7272 func testIndexTraversals( ) {
7373 validateIndexTraversals ( ( 1 ... 5 ) . adjacentPairs ( ) )
7474 }
75+
76+ func testLaziness( ) {
77+ XCTAssertLazySequence ( ( 0 ... ) . lazy. adjacentPairs ( ) )
78+ XCTAssertLazyCollection ( ( 0 ..< 100 ) . lazy. adjacentPairs ( ) )
79+ }
7580}
You can’t perform that action at this time.
0 commit comments