Usage of withMemoryRebound with Apples Swift 3 beta 6
<p>I have the following Problem. I want to convert my old function (worked until Swift 3 beta 5):</p>

<pre><code>func binarytotype &lt;T&gt; (_ value: [UInt8], _: T.Type) -&gt; T
{
    return value.withUnsafeBufferPointer
    {
        return UnsafePointer&lt;T&gt;($0.baseAddress!).pointee
    }
}
</code></pre>

<p>To Swift 3 beta 6 Syntax. This function converts an array of UInt8 to another type, for example:</p>

<pre><code>let b: [UInt8] = [1,2,3,4,5,6,7,8]
var number: Double = binarytotype(b, Double.self)
</code></pre>

<p>But for now this does not work any more in beta 6 and I have to use withMemoryRebound but I really do not know, how to make it run. Can anybody help me?</p>

<p>The reverse function of this was:</p>

<pre><code>func typetobinary &lt;T&gt; (_ value: T) -&gt; [UInt8]
{
    var v: T = value
    return withUnsafePointer(to: &amp;v)
    {
        Array(UnsafeBufferPointer(start: UnsafePointer&lt;UInt8&gt;($0), count: MemoryLayout&lt;T&gt;.size))
    }
}
</code></pre>

<p>This does not work any more, too. Same problem. Both are needed for some of my projects. This reverse function was called as:</p>

<pre><code>var binary: [UInt8] = typetobinary(number)
</code></pre>