adwaita-swift/Sources/Core/Model/Extensions/UnsafeMutablePointer.swift
david-swift 8eeda083e9
All checks were successful
Deploy Docs / publish (push) Successful in 18m28s
SwiftLint / SwiftLint (push) Successful in 5s
Separate AnyView extensions from widgets
2024-10-16 14:22:34 +02:00

24 lines
598 B
Swift

//
// UnsafeMutablePointer.swift
// Adwaita
//
// Created by david-swift on 15.01.24.
//
extension UnsafeMutablePointer {
/// Convert into an opaque pointer.
/// - Returns: The opaque pointer.
public func opaque() -> OpaquePointer {
.init(self)
}
/// Convert into an unsafe mutable pointer of another type.
/// - Returns: The unsafe mutable pointer.
public func cast<T>() -> UnsafeMutablePointer<T> {
let pointer = UnsafeMutableRawPointer(self).bindMemory(to: T.self, capacity: 1)
return UnsafeMutablePointer<T>(mutating: pointer)
}
}