diff --git a/Sources/ConsoleKit/Terminal/Terminal.swift b/Sources/ConsoleKit/Terminal/Terminal.swift index 5adeb75..9c6ef78 100644 --- a/Sources/ConsoleKit/Terminal/Terminal.swift +++ b/Sources/ConsoleKit/Terminal/Terminal.swift @@ -8,20 +8,6 @@ import CRT import Foundation import NIOConcurrencyHelpers -/// A `Sendable` version of the standard library's `AnyHashable` type. -public struct AnySendableHashable: @unchecked Sendable, Hashable, ExpressibleByStringLiteral { - // Note: @unchecked Sendable since there's no way to express that `wrappedValue` is Sendable, even though we ensure that it is in the init. - let wrappedValue: AnyHashable - - public init(_ wrappedValue: any Hashable & Sendable) { - self.wrappedValue = AnyHashable(wrappedValue) - } - - public init(stringLiteral value: String) { - self.init(value) - } -} - /// Generic console that uses a mixture of Swift standard /// library and Foundation code to fulfill protocol requirements. public final class Terminal: Console, Sendable { diff --git a/Sources/ConsoleKit/Utilities/AnySendableHashable.swift b/Sources/ConsoleKit/Utilities/AnySendableHashable.swift new file mode 100644 index 0000000..dddf26b --- /dev/null +++ b/Sources/ConsoleKit/Utilities/AnySendableHashable.swift @@ -0,0 +1,19 @@ +/// A `Sendable` version of the standard library's `AnyHashable` type. +public struct AnySendableHashable: @unchecked Sendable, Hashable, ExpressibleByStringLiteral { + // Note: @unchecked Sendable since there's no way to express that `wrappedValue` is Sendable, even though we ensure that it is in the init. + let wrappedValue: AnyHashable + + public init(_ wrappedValue: some Hashable & Sendable) { + self.wrappedValue = AnyHashable(wrappedValue) + } + + public init(stringLiteral value: String) { + self.init(value) + } +} + +extension AnySendableHashable: CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable { + public var description: String { self.wrappedValue.description } + public var debugDescription: String { self.wrappedValue.debugDescription } + public var customMirror: Mirror { self.wrappedValue.customMirror } +}