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 {
527527 public func extracting( _ bounds: some RangeExpression < Int > ) -> Self {
528528 extracting ( bounds. relative ( to: Range ( uncheckedBounds: ( 0 , count) ) ) )
529529 }
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+ }
530549}
531550
532551@_disallowFeatureSuppression ( NoncopyableGenerics)
You can’t perform that action at this time.
0 commit comments