UnsafeMutablePointer usage in Swift 3
<p>I am using the following extension for UIBezierPath:</p>

<pre><code>extension UIBezierPath {

    var elements: [PathElement] {

        var pathElements = [PathElement]()

        withUnsafeMutablePointer(&amp;pathElements) { elementsPointer in

            CGPathApply(CGPath, elementsPointer) { (userInfo, nextElementPointer) in

                let nextElement = PathElement(element: nextElementPointer.memory)

                let elementsPointer = UnsafeMutablePointer&lt;[PathElement]&gt;(userInfo)

                elementsPointer.memory.append(nextElement)
            }
        }
        return pathElements
    }
}
</code></pre>

<p>This is from the site:</p>

<blockquote>
  <p><a href="https://oleb.net/blog/2015/06/c-callbacks-in-swift/" rel="nofollow">https://oleb.net/blog/2015/06/c-callbacks-in-swift/</a></p>
</blockquote>

<p>However, this breaks with Swift 3 for the following line:</p>

<pre><code>let elementsPointer = UnsafeMutablePointer&lt;[PathElement]&gt;(userInfo)
</code></pre>

<p>Following error is displayed:</p>

<pre><code>Cannot invade initializer for type 'UnsafeMutablePointer&lt;[PathElement]&gt;' with an argument list of type '(UnsafeMutableRawPointer?)'
</code></pre>

<p>I understand that this is related to the change in Swift 3:<code>UnsafeRawPointerMigration</code></p>

<blockquote>
  <p><a href="https://swift.org/migration-guide/se-0107-migrate.html" rel="nofollow">https://swift.org/migration-guide/se-0107-migrate.html</a></p>
</blockquote>

<p>However, I am not quite sure the best way to port this to Swift 3.  Would you be able to provide some help in this regard w/ updated code for the above extension?</p>