File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Tests/SwiftAlgorithmsTests Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ extension StridingSequence: Sequence {
112112 }
113113}
114114
115+ extension StridingSequence : LazySequenceProtocol
116+ where Base: LazySequenceProtocol { }
117+
115118/// A wrapper that strides over a base collection.
116119public struct StridingCollection < Base: Collection > {
117120 @usableFromInline
@@ -273,4 +276,8 @@ extension StridingCollection: BidirectionalCollection
273276
274277extension StridingCollection : RandomAccessCollection
275278 where Base: RandomAccessCollection { }
279+
280+ extension StridingCollection : LazySequenceProtocol , LazyCollectionProtocol
281+ where Base: LazySequenceProtocol { }
282+
276283extension StridingCollection . Index : Hashable where Base. Index: Hashable { }
Original file line number Diff line number Diff line change @@ -119,7 +119,6 @@ final class StridingTests: XCTestCase {
119119 validator. validate ( string. striding ( by: 10 ) )
120120 }
121121 }
122-
123122
124123 func testOffsetBy( ) {
125124 let a = ( 0 ... 100 ) . striding ( by: 22 )
@@ -135,4 +134,10 @@ final class StridingTests: XCTestCase {
135134 let i = b. index ( b. startIndex, offsetBy: 2 )
136135 XCTAssertEqual ( i, b. endIndex)
137136 }
137+
138+ func testLazy( ) {
139+ XCTAssertLazySequence ( AnySequence ( 0 ..< 100 ) . lazy. striding ( by: 3 ) )
140+ XCTAssertLazySequence ( ( 0 ..< 100 ) . lazy. striding ( by: 3 ) )
141+ XCTAssertLazyCollection ( ( 0 ..< 100 ) . lazy. striding ( by: 3 ) )
142+ }
138143}
You can’t perform that action at this time.
0 commit comments