Created
February 9, 2021 06:23
-
-
Save inamiy/98575ec47e06b0cd52efbdec0e0c2b52 to your computer and use it in GitHub Desktop.
Recursive struct in Swift using Box (indirect struct)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
class Box<T> { | |
var wrappedValue: T | |
var projectedValue: Box<T> { | |
Box(wrappedValue) | |
} | |
init(_ value: T) { | |
self.wrappedValue = value | |
} | |
} | |
struct Foo { | |
@Box | |
var foo: Foo | |
} | |
// SeeAlso: https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#ref--box |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment