@@ -161,7 +161,7 @@ extension Slice where Base == UnsafeMutableRawBufferPointer {
161
161
@discardableResult
162
162
@inlinable
163
163
@_alwaysEmitIntoClient
164
- public func moveInitializeMemory< T> (
164
+ public func moveInitializeMemory< T: ~ Copyable > (
165
165
as type: T . Type ,
166
166
fromContentsOf source: UnsafeMutableBufferPointer < T >
167
167
) -> UnsafeMutableBufferPointer < T > {
@@ -228,7 +228,9 @@ extension Slice where Base == UnsafeMutableRawBufferPointer {
228
228
@discardableResult
229
229
@inlinable
230
230
@_alwaysEmitIntoClient
231
- public func bindMemory< T> ( to type: T . Type ) -> UnsafeMutableBufferPointer < T > {
231
+ public func bindMemory< T: ~ Copyable> (
232
+ to type: T . Type
233
+ ) -> UnsafeMutableBufferPointer < T > {
232
234
let buffer = unsafe Base( rebasing: self )
233
235
return unsafe buffer. bindMemory ( to: T . self)
234
236
}
@@ -279,8 +281,9 @@ extension Slice where Base == UnsafeMutableRawBufferPointer {
279
281
/// - Returns: The return value, if any, of the `body` closure parameter.
280
282
@inlinable
281
283
@_alwaysEmitIntoClient
282
- public func withMemoryRebound< T, Result, E: Error > (
283
- to type: T . Type , _ body: ( UnsafeMutableBufferPointer < T > ) throws ( E ) -> Result
284
+ public func withMemoryRebound< T: ~ Copyable, E: Error , Result: ~ Copyable> (
285
+ to type: T . Type ,
286
+ _ body: ( UnsafeMutableBufferPointer < T > ) throws ( E ) -> Result
284
287
) throws ( E) -> Result {
285
288
let buffer = unsafe Base( rebasing: self )
286
289
return try unsafe buffer. withMemoryRebound ( to: T . self, body)
@@ -304,7 +307,7 @@ extension Slice where Base == UnsafeMutableRawBufferPointer {
304
307
/// - Returns: A typed pointer to the same memory as this raw pointer.
305
308
@inlinable
306
309
@_alwaysEmitIntoClient
307
- public func assumingMemoryBound< T> (
310
+ public func assumingMemoryBound< T: ~ Copyable > (
308
311
to type: T . Type
309
312
) -> UnsafeMutableBufferPointer < T > {
310
313
let buffer = unsafe Base( rebasing: self )
@@ -465,7 +468,9 @@ extension Slice where Base == UnsafeRawBufferPointer {
465
468
@discardableResult
466
469
@inlinable
467
470
@_alwaysEmitIntoClient
468
- public func bindMemory< T> ( to type: T . Type ) -> UnsafeBufferPointer < T > {
471
+ public func bindMemory< T: ~ Copyable> (
472
+ to type: T . Type
473
+ ) -> UnsafeBufferPointer < T > {
469
474
let buffer = unsafe Base( rebasing: self )
470
475
return unsafe buffer. bindMemory ( to: T . self)
471
476
}
@@ -516,8 +521,9 @@ extension Slice where Base == UnsafeRawBufferPointer {
516
521
/// - Returns: The return value, if any, of the `body` closure parameter.
517
522
@inlinable
518
523
@_alwaysEmitIntoClient
519
- public func withMemoryRebound< T, Result, E: Error > (
520
- to type: T . Type , _ body: ( UnsafeBufferPointer < T > ) throws ( E ) -> Result
524
+ public func withMemoryRebound< T: ~ Copyable, E: Error , Result: ~ Copyable> (
525
+ to type: T . Type ,
526
+ _ body: ( UnsafeBufferPointer < T > ) throws ( E ) -> Result
521
527
) throws ( E) -> Result {
522
528
let buffer = unsafe Base( rebasing: self )
523
529
return try unsafe buffer. withMemoryRebound ( to: T . self, body)
@@ -541,7 +547,7 @@ extension Slice where Base == UnsafeRawBufferPointer {
541
547
/// - Returns: A typed pointer to the same memory as this raw pointer.
542
548
@inlinable
543
549
@_alwaysEmitIntoClient
544
- public func assumingMemoryBound< T> (
550
+ public func assumingMemoryBound< T: ~ Copyable > (
545
551
to type: T . Type
546
552
) -> UnsafeBufferPointer < T > {
547
553
let buffer = unsafe Base( rebasing: self )
@@ -693,9 +699,14 @@ extension Slice {
693
699
/// - Returns: The return value, if any, of the `body` closure parameter.
694
700
@inlinable
695
701
@_alwaysEmitIntoClient
696
- public func withMemoryRebound< T, Result, Element> (
697
- to type: T . Type , _ body: ( UnsafeBufferPointer < T > ) throws -> Result
698
- ) rethrows -> Result where Base == UnsafeBufferPointer < Element > {
702
+ public func withMemoryRebound<
703
+ T: ~ Copyable, E: Error , Result: ~ Copyable, Element
704
+ > (
705
+ to type: T . Type ,
706
+ _ body: ( UnsafeBufferPointer < T > ) throws ( E ) -> Result
707
+ ) throws ( E) -> Result
708
+ where Base == UnsafeBufferPointer < Element >
709
+ {
699
710
let rebased = unsafe UnsafeBufferPointer< Element > ( rebasing: self )
700
711
return try unsafe rebased. withMemoryRebound ( to: T . self, body)
701
712
}
@@ -1136,9 +1147,14 @@ extension Slice {
1136
1147
/// - Returns: The return value, if any, of the `body` closure parameter.
1137
1148
@inlinable
1138
1149
@_alwaysEmitIntoClient
1139
- public func withMemoryRebound< T, Result, Element> (
1140
- to type: T . Type , _ body: ( UnsafeMutableBufferPointer < T > ) throws -> Result
1141
- ) rethrows -> Result where Base == UnsafeMutableBufferPointer < Element > {
1150
+ public func withMemoryRebound<
1151
+ T: ~ Copyable, E: Error , Result: ~ Copyable, Element
1152
+ > (
1153
+ to type: T . Type ,
1154
+ _ body: ( UnsafeMutableBufferPointer < T > ) throws ( E ) -> Result
1155
+ ) throws ( E) -> Result
1156
+ where Base == UnsafeMutableBufferPointer < Element >
1157
+ {
1142
1158
try unsafe Base( rebasing: self ) . withMemoryRebound ( to: T . self, body)
1143
1159
}
1144
1160
0 commit comments