diff --git a/Package.swift b/Package.swift index 27ee3d2..a9f7326 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription let package:Package = .init( name: "swift-hash", - platforms: [.macOS("13.3"), .iOS("16.4"), .tvOS("16.4"), .watchOS("9.4")], + platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)], products: [ .library(name: "Base16", targets: ["Base16"]), .library(name: "Base64", targets: ["Base64"]), diff --git a/Sources/InlineBuffer/InlineBuffer.swift b/Sources/InlineBuffer/InlineBuffer.swift index d947b28..c56ee36 100644 --- a/Sources/InlineBuffer/InlineBuffer.swift +++ b/Sources/InlineBuffer/InlineBuffer.swift @@ -100,6 +100,7 @@ extension InlineBuffer:RandomAccessCollection, MutableCollection } } } +@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *) extension InlineBuffer:ExpressibleByIntegerLiteral { @inlinable public @@ -153,18 +154,32 @@ extension InlineBuffer:CustomStringConvertible @inlinable public var description:String { - .init(unsafeUninitializedCapacity: 2 * self.count) + func hex(remainder:UInt8) -> UInt8 { - func hex(remainder:UInt8) -> UInt8 + (remainder < 10 ? 0x30 : 0x61 - 10) &+ remainder + } + if #available(macOS 11, iOS 14, macCatalyst 14, tvOS 14, visionOS 1, watchOS 7, *) + { + return .init(unsafeUninitializedCapacity: 2 * self.count) { - (remainder < 10 ? 0x30 : 0x61 - 10) &+ remainder + for (i, byte):(Int, UInt8) in self.enumerated() + { + $0[2 * i ] = hex(remainder: byte >> 4) + $0[2 * i + 1] = hex(remainder: byte & 0x0f) + } + return 2 * self.count } - for (i, byte):(Int, UInt8) in self.enumerated() + } + else + { + var description:String = "" + description.reserveCapacity(2 * self.count) + for byte:UInt8 in self { - $0[2 * i ] = hex(remainder: byte >> 4) - $0[2 * i + 1] = hex(remainder: byte & 0x0f) + description.append(Character.init(.init(hex(remainder: byte >> 4)))) + description.append(Character.init(.init(hex(remainder: byte & 0x0f)))) } - return 2 * self.count + return description } } } diff --git a/Sources/MD5/MD5.swift b/Sources/MD5/MD5.swift index cb9d4f5..66a2283 100644 --- a/Sources/MD5/MD5.swift +++ b/Sources/MD5/MD5.swift @@ -100,6 +100,7 @@ extension MD5:LosslessStringConvertible } } } +@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *) extension MD5:ExpressibleByIntegerLiteral { @inlinable public diff --git a/Sources/MD5Tests/Main.swift b/Sources/MD5Tests/Main.swift index 3c9a3c7..9282d5f 100644 --- a/Sources/MD5Tests/Main.swift +++ b/Sources/MD5Tests/Main.swift @@ -7,6 +7,20 @@ enum Main:TestMain, TestBattery static func run(tests:TestGroup) { + guard #available( + macOS 13.3, + iOS 16.4, + macCatalyst 16.4, + tvOS 16.4, + visionOS 1.0, + watchOS 9.4, + * + ) + else + { + fatalError("MD5Tests requires macOS 13.3+, iOS 16.4+, tvOS 16.4+, visionOS 1.0+, or watchOS 9.4+") + } + if let tests:TestGroup = tests / "Strings" { let string:String = "d41d8cd98f00b204e9800998ecf8427e" diff --git a/Sources/SHA1/SHA1.swift b/Sources/SHA1/SHA1.swift index 1e180da..2b74299 100644 --- a/Sources/SHA1/SHA1.swift +++ b/Sources/SHA1/SHA1.swift @@ -83,6 +83,7 @@ extension SHA1:LosslessStringConvertible } } } +@available(macOS 13.3, iOS 16.4, macCatalyst 16.4, tvOS 16.4, visionOS 1, watchOS 9.4, *) extension SHA1:ExpressibleByIntegerLiteral { @inlinable public