将 UnsafeMutablePointer 转换为 UnsafePointer

Convert UnsafeMutablePointer to UnsafePointer

我在我的 Swift 项目中使用了一个 C 库,其中一个函数需要一个 UnsafePointer<UnsafePointer<UInt8>?>! 作为我应该传递数据的输入输出参数。但问题是我有 UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>! 类型的数据。

我的问题是 - 在 Swift 3 中将 UnsafeMutablePointer 转换为 UnsafePointer 的最有效和最简单的方法是什么?这些指针没有太大区别 "on paper",它们与技术上下文应该没有太大区别,但我找不到关于该主题的有价值信息。

如有任何帮助,我们将不胜感激。谢谢

UnsafePointers can be initialized with an UnsafeMutablePointer

// Any UnsafeMutablePointer with capacity one
let ump = UnsafeMutablePointer<Any>.allocate(capacity: 1)
// `up` now contains an UnsafePointer initialized with `ump`
var up = UnsafePointer(ump)