mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This implements support for autoclosures, closures and local functions nested within a pack iteration for loop. The combination of explicit closure expressions and pack expansion expressions still needs some work. Fixes #66917. Fixes #69947. Fixes rdar://113505724. Fixes rdar://122293832. Fixes rdar://124329076.
16 lines
397 B
Swift
16 lines
397 B
Swift
// RUN: %target-swift-frontend -emit-ir %s
|
|
|
|
func withPointerToElements<each T, E, R>(
|
|
of tuple: borrowing (repeat each T),
|
|
_ body: (UnsafeBufferPointer<E>) -> R
|
|
) -> R {
|
|
for t in repeat (each T).self {
|
|
if t != E.self {
|
|
preconditionFailure()
|
|
}
|
|
}
|
|
return withUnsafeBytes(of: tuple) { p in
|
|
return body(p.assumingMemoryBound(to: E.self))
|
|
}
|
|
}
|