We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aca36f5 commit c5b3316Copy full SHA for c5b3316
stdlib/public/core/UnsafePointer.swift
@@ -410,6 +410,19 @@ extension UnsafePointer where Pointee: ~Copyable {
410
),
411
"self must be a properly aligned pointer for types Pointee and T"
412
)
413
+ return try unsafe _uncheckedWithMemoryRebound(
414
+ to: type, capacity: count, body)
415
+ }
416
+
417
+ @_alwaysEmitIntoClient
418
+ @_transparent
419
+ internal func _uncheckedWithMemoryRebound<
420
+ T: ~Copyable, E: Error, Result: ~Copyable
421
+ >(
422
+ to type: T.Type,
423
+ capacity count: Int,
424
+ _ body: (_ pointer: UnsafePointer<T>) throws(E) -> Result
425
+ ) throws(E) -> Result {
426
let binding = Builtin.bindMemory(_rawValue, count._builtinWordValue, T.self)
427
defer { Builtin.rebindMemory(_rawValue, binding) }
428
return try unsafe body(.init(_rawValue))
0 commit comments