Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func tupleToArray<T, U>(var tuple: T, _ resultType: U.Type) -> [U] {
let count = sizeof(T) / sizeof(U)
return withUnsafePointer(&tuple) { ptr -> [U] in
let eltPtr = UnsafePointer<U>(ptr)
return Array(0..<count).map({ eltPtr[$0] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.