Created
December 8, 2023 16:00
-
-
Save rickytan/d65f3456f7895a6290f892c39f07dada to your computer and use it in GitHub Desktop.
Swift Namewrapper
This file contains hidden or 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
public struct NameWrapper<Base> { | |
public let base: Base | |
public init(_ base: Base) { | |
self.base = base | |
} | |
} | |
public protocol NameWrapperCompatiable { | |
associatedtype Base | |
static var <#namespace#>: NameWrapper<Base>.Type { get set } | |
var <#namespace#>: NameWrapper<Base> { get set } | |
} | |
public extension NameWrapperCompatiable { | |
var <#namespace#>: NameWrapper<Self> { | |
get { return NameWrapper(self) } | |
// swiftlint:disable:next unused_setter_value | |
set { } | |
} | |
static var <#namespace#>: NameWrapper<Self>.Type { | |
get { return NameWrapper<Self>.self } | |
// swiftlint:disable:next unused_setter_value | |
set { } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment