@@ -68,8 +68,7 @@ public struct Unsafe${Mutable}BufferPointer<Element>
68
68
69
69
public typealias Index = Int
70
70
public typealias IndexDistance = Int
71
- public typealias Iterator =
72
- IndexingIterator < Unsafe ${ Mutable} BufferPointer< Element > >
71
+ public typealias Iterator = UnsafeBufferPointerIterator < Element >
73
72
74
73
/// The index of the first element in a nonempty buffer.
75
74
///
@@ -183,6 +182,28 @@ public struct Unsafe${Mutable}BufferPointer<Element>
183
182
return startIndex..< endIndex
184
183
}
185
184
185
+ /// Copies `self` into the supplied buffer.
186
+ ///
187
+ /// - Precondition: The memory in `self` is uninitialized. The buffer must
188
+ /// contain sufficient uninitialized memory to accommodate `source.underestimatedCount`.
189
+ ///
190
+ /// - Postcondition: The `Pointee`s at `buffer[startIndex..<returned index]` are
191
+ /// initialized.
192
+ public func _copyContents(
193
+ initializing buffer: UnsafeMutableBufferPointer < Iterator . Element >
194
+ ) -> ( Iterator , UnsafeMutableBufferPointer < Iterator . Element > . Index ) {
195
+ guard !isEmpty else { return ( makeIterator ( ) , buffer. startIndex) }
196
+
197
+ guard count <= buffer. count, let ptr = buffer. baseAddress else {
198
+ fatalError ( " Insufficient space allocated to copy buffer contents " )
199
+ }
200
+
201
+ ptr. initialize ( from: baseAddress!, count: self . count)
202
+ var it : Iterator = self . makeIterator ( )
203
+ it. _position = it. _end
204
+ return ( it, buffer. index ( buffer. startIndex, offsetBy: self . count) )
205
+ }
206
+
186
207
/// Accesses the element at the specified position.
187
208
///
188
209
% if Mutable:
0 commit comments