Last active
July 5, 2020 12:36
-
-
Save maximkrouk/27dc0671a890af6eda08771a5d975316 to your computer and use it in GitHub Desktop.
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
@dynamicMemberLookup | |
@propertyWrapper | |
public <#class or struct#> <#Prefix#>Box<Content> { | |
public var content: Content | |
@inlinable | |
public var wrappedValue: Content { | |
get { content } | |
set { content = newValue } | |
} | |
// @inlinable | |
// var projectedValue: <#Type#> { <#code#> } | |
@inlinable | |
public init(wrappedValue: Content) { | |
self.init(wrappedValue) | |
} | |
@inlinable | |
public init(_ content: Content) { | |
self.content = content | |
} | |
@inlinable | |
public subscript<T>(dynamicMember keyPath: KeyPath<Content, T>) -> T { | |
get { content[keyPath: keyPath] } | |
} | |
@inlinable | |
public subscript<T>(dynamicMember keyPath: WritableKeyPath<Content, T>) -> T { | |
get { content[keyPath: keyPath] } | |
set { content[keyPath: keyPath] = newValue } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See more:
Back to index