diff --git a/Sources/Tagged/Tagged.swift b/Sources/Tagged/Tagged.swift index 995ea7c..e3d57aa 100644 --- a/Sources/Tagged/Tagged.swift +++ b/Sources/Tagged/Tagged.swift @@ -6,6 +6,10 @@ public struct Tagged { self.rawValue = rawValue } + public init(_ rawValue: RawValue) { + self.rawValue = rawValue + } + public func map(_ f: (RawValue) -> B) -> Tagged { return .init(rawValue: f(self.rawValue)) } diff --git a/Tests/TaggedTests/TaggedTests.swift b/Tests/TaggedTests/TaggedTests.swift index c98590c..0fc1416 100644 --- a/Tests/TaggedTests/TaggedTests.swift +++ b/Tests/TaggedTests/TaggedTests.swift @@ -5,6 +5,12 @@ enum Tag {} struct Unit: Error {} final class TaggedTests: XCTestCase { + func testInit() { + let int1 = Tagged(rawValue: 42) + let int2 = Tagged(1729) + XCTAssertNotEqual(int1, int2) + } + func testCustomStringConvertible() { XCTAssertEqual("1", Tagged(rawValue: 1).description) }