mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
23 lines
407 B
Swift
23 lines
407 B
Swift
@propertyWrapper
|
|
public struct MyPublished<Value> {
|
|
private var stored: Value
|
|
|
|
public var wrappedValue: Value {
|
|
get { stored }
|
|
set { stored = newValue }
|
|
}
|
|
|
|
public init(wrappedValue initialValue: Value) {
|
|
stored = initialValue
|
|
}
|
|
|
|
public var projectedValue: Self {
|
|
mutating get { self }
|
|
set { self = newValue }
|
|
}
|
|
}
|
|
|
|
public class UsesMyPublished {
|
|
@MyPublished public var foo: Int = 17
|
|
}
|