File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -527,6 +527,25 @@ extension Unsafe${Mutable}BufferPointer where Element: ~Copyable {
527
527
public func extracting( _ bounds: some RangeExpression < Int > ) -> Self {
528
528
extracting ( bounds. relative ( to: Range ( uncheckedBounds: ( 0 , count) ) ) )
529
529
}
530
+
531
+ /// Extracts and returns a copy of the entire buffer.
532
+ ///
533
+ /// When `Element` is copyable, the `extracting` operation is equivalent to
534
+ /// slicing the buffer then rebasing the resulting buffer slice:
535
+ ///
536
+ /// let a = buffer
537
+ /// let b = buffer.extracting(...)
538
+ /// let c = UnsafeBufferPointer(rebasing: buffer[...])
539
+ /// // `a`, `b` and `c` are now all referring to the same buffer
540
+ ///
541
+ /// Note that unlike slicing, the `extracting` operation remains available
542
+ /// even if `Element` happens to be noncopyable.
543
+ //
544
+ /// - Returns: The same buffer as `self`.
545
+ @_alwaysEmitIntoClient
546
+ public func extracting( _ bounds: UnboundedRange ) -> Self {
547
+ self
548
+ }
530
549
}
531
550
532
551
@_disallowFeatureSuppression ( NoncopyableGenerics)
You can’t perform that action at this time.
0 commit comments