Atomic Reference Cell
This project provide two structures: Arc<T>
and WeakArc<T>
for Swift.
Usage
Dereference:
let x: Arc<Int> = Arc(1)
let y: Arc<Int> = Arc(2)
let z: Int = *x + *y
assert(z == 3)
To invoke a method:
let x: Arc<Int> = Arc(1)
let y = (*x).distance(to: 3)
assert(y == 2)
To make weak reference:
let x: Arc<Int> = Arc(1)
let y: WeakArc<Int> = x.weak()
let z: Int? = *y
assert(z == 1)
Installation
SwiftPM:
.package(url: "https://github.com/cjwcommuny/AtomicReferenceCell", from: "0.1.0")