1
1
// Adapted from https://github.com/pointfreeco/swift-gen
2
2
// Copyright (c) 2019 Point-Free, Inc. MIT License
3
3
4
+ #if compiler(>=6.2)
5
+ @_documentation ( visibility: internal)
6
+ public typealias SendableHashableType = Hashable & SendableMetatype
7
+ #else
8
+ @_documentation ( visibility: internal)
9
+ public typealias SendableHashableType = Hashable
10
+ #endif
11
+
4
12
extension Gen {
5
13
/// Produces a generator of random elements of the given collection.
6
14
///
@@ -116,7 +124,9 @@ extension Generator {
116
124
/// - Parameter count: The size of the random dictionary. If duplicate keys are generated, the dictionary will have a smaller size.
117
125
/// - Returns: A generator of dictionaries.
118
126
@inlinable
119
- public func dictionary< K: Hashable , V> ( ofAtMost count: ClosedRange < Int > ) -> Generator < [ K : V ] , ArrayShrink >
127
+ public func dictionary< K: SendableHashableType , V> ( ofAtMost count: ClosedRange < Int > ) -> Generator <
128
+ [ K : V ] , ArrayShrink
129
+ >
120
130
where ResultValue == ( K , V ) {
121
131
return array ( of: count) . map {
122
132
Dictionary ( $0, uniquingKeysWith: { a, _ in a } )
@@ -136,13 +146,13 @@ extension Generator {
136
146
/// - Parameter count: The size of the random dictionary. If duplicate keys are generated, the dictionary will have a smaller size.
137
147
/// - Returns: A generator of dictionaries.
138
148
@inlinable
139
- public func dictionary< K: Hashable , V> ( ofAtMost count: Int ) -> Generator < [ K : V ] , ArrayShrink >
149
+ public func dictionary< K: SendableHashableType , V> ( ofAtMost count: Int ) -> Generator < [ K : V ] , ArrayShrink >
140
150
where ResultValue == ( K , V ) {
141
151
return dictionary ( ofAtMost: count... count)
142
152
}
143
153
}
144
154
145
- extension Generator where ResultValue: Hashable {
155
+ extension Generator where ResultValue: SendableHashableType {
146
156
/// Produces a new generator of sets of this generator's values.
147
157
///
148
158
/// ### Example
@@ -172,7 +182,7 @@ extension Generator where ResultValue: Hashable {
172
182
}
173
183
}
174
184
175
- extension Gen where Value: OptionSet , Value. RawValue: FixedWidthInteger & Sendable {
185
+ extension Gen where Value: OptionSet & Sendable , Value. RawValue: FixedWidthInteger & Sendable {
176
186
/// Produces a generator of sets for an OptionSet.
177
187
///
178
188
/// This generator will generate sets that may exceed the static properties declared in this option set.
0 commit comments