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 {
112
112
}
113
113
}
114
114
115
+ extension StridingSequence : LazySequenceProtocol
116
+ where Base: LazySequenceProtocol { }
117
+
115
118
/// A wrapper that strides over a base collection.
116
119
public struct StridingCollection < Base: Collection > {
117
120
@usableFromInline
@@ -273,4 +276,8 @@ extension StridingCollection: BidirectionalCollection
273
276
274
277
extension StridingCollection : RandomAccessCollection
275
278
where Base: RandomAccessCollection { }
279
+
280
+ extension StridingCollection : LazySequenceProtocol , LazyCollectionProtocol
281
+ where Base: LazySequenceProtocol { }
282
+
276
283
extension 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 {
119
119
validator. validate ( string. striding ( by: 10 ) )
120
120
}
121
121
}
122
-
123
122
124
123
func testOffsetBy( ) {
125
124
let a = ( 0 ... 100 ) . striding ( by: 22 )
@@ -135,4 +134,10 @@ final class StridingTests: XCTestCase {
135
134
let i = b. index ( b. startIndex, offsetBy: 2 )
136
135
XCTAssertEqual ( i, b. endIndex)
137
136
}
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
+ }
138
143
}
You can’t perform that action at this time.
0 commit comments