@@ -196,7 +196,7 @@ extension DER {
196
196
/// - rootNode: The ``ASN1Node`` to parse
197
197
/// - returns: A `Sequence` of elements representing the `Result` of parsing the elements in the sequence.
198
198
@inlinable
199
- public static func lazySet< T: DERParseable > ( of: T . Type = T . self, identifier: ASN1Identifier , rootNode: ASN1Node ) throws -> some Sequence < Result < T , Error > > {
199
+ public static func lazySet< T: DERParseable > ( of: T . Type = T . self, identifier: ASN1Identifier , rootNode: ASN1Node ) throws -> LazySetOfSequence < T > {
200
200
guard rootNode. identifier == identifier, case . constructed( let nodes) = rootNode. content else {
201
201
throw ASN1Error . unexpectedFieldType ( rootNode. identifier)
202
202
}
@@ -205,7 +205,42 @@ extension DER {
205
205
throw ASN1Error . invalidASN1Object ( reason: " SET OF fields are not lexicographically ordered " )
206
206
}
207
207
208
- return nodes. lazy. map { node in Result { try T ( derEncoded: node) } }
208
+ return . init( nodes. lazy. map { node in Result { try T ( derEncoded: node) } } )
209
+ }
210
+
211
+ public struct LazySetOfSequence < T> : Sequence {
212
+ public typealias Element = Result < T , Error >
213
+
214
+ @usableFromInline
215
+ typealias WrappedSequence = LazyMapSequence < LazySequence < ( ASN1NodeCollection ) > . Elements , Result < T , Error > >
216
+
217
+ public struct Iterator : IteratorProtocol {
218
+ @usableFromInline
219
+ var wrapped : WrappedSequence . Iterator
220
+
221
+ @inlinable
222
+ mutating public func next( ) -> Element ? {
223
+ wrapped. next ( )
224
+ }
225
+
226
+ @inlinable
227
+ init ( _ wrapped: WrappedSequence . Iterator ) {
228
+ self . wrapped = wrapped
229
+ }
230
+ }
231
+
232
+ @usableFromInline
233
+ var wrapped : WrappedSequence
234
+
235
+ @inlinable
236
+ init ( _ wrapped: WrappedSequence ) {
237
+ self . wrapped = wrapped
238
+ }
239
+
240
+ @inlinable
241
+ public func makeIterator( ) -> Iterator {
242
+ . init( wrapped. makeIterator ( ) )
243
+ }
209
244
}
210
245
}
211
246
0 commit comments