Last active
January 13, 2017 10:56
-
-
Save MP0w/55056abd76d526ed231b598b5c959e89 to your computer and use it in GitHub Desktop.
Dummy
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
import Foundation | |
/// Creates a Test dummy of the needed type! | |
/// Works with any value type or class (?) | |
func dummy<T>() -> T { | |
let size = MemoryLayout<T>.size | |
let alignment = MemoryLayout<T>.alignment | |
let p = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: alignment) | |
return p.bindMemory(to: T.self, capacity: 1).pointee | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment