mirror of
https://github.com/insidegui/VirtualBuddy.git
synced 2026-12-02 07:20:22 +08:00
15 lines
467 B
Swift
15 lines
467 B
Swift
import Foundation
|
|
|
|
/// Wraps a reference type as a weak reference.
|
|
/// Useful as value type in collections when holding a strong reference to the objects is undesirable.
|
|
public struct WeakReference<Object: AnyObject> {
|
|
public private(set) weak var object: Object?
|
|
|
|
public init(_ object: Object) {
|
|
self.object = object
|
|
}
|
|
}
|
|
|
|
extension WeakReference: Equatable where Object: Equatable { }
|
|
extension WeakReference: Hashable where Object: Hashable { }
|