Created
September 23, 2015 08:23
-
-
Save ttilley/a9bef59dd0cb93fb52a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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