From 5c6e534ea901a16888b81c93d09cc86662ed353b Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 13 Dec 2022 11:42:11 -0500 Subject: [PATCH] Support `ExpressibleByNilLiteral` Just for discussion for now. The use case seems appropriate, but given optional promotion in the language, maybe it's best to avoid potential type-checking issues. --- Sources/Tagged/Tagged.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Tagged/Tagged.swift b/Sources/Tagged/Tagged.swift index e3d57aa..c861b33 100644 --- a/Sources/Tagged/Tagged.swift +++ b/Sources/Tagged/Tagged.swift @@ -147,6 +147,12 @@ extension Tagged: ExpressibleByIntegerLiteral where RawValue: ExpressibleByInteg } } +extension Tagged: ExpressibleByNilLiteral where RawValue: ExpressibleByNilLiteral { + public init(nilLiteral: ()) { + self.init(rawValue: RawValue(nilLiteral: nilLiteral)) + } +} + extension Tagged: ExpressibleByStringLiteral where RawValue: ExpressibleByStringLiteral { public typealias StringLiteralType = RawValue.StringLiteralType