File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,24 @@ extension ContiguousArray: Equatable where Element: Equatable { /*== already exi
304
304
extension Dictionary : Equatable where Value : Equatable { /* == already exists */ }
305
305
```
306
306
307
- Note that ` Set ` is already (unconditionally) ` Equatable ` .
307
+ In addition, implement conditional conformances to ` Hashable ` for the
308
+ types above, as well as ` Range ` and ` ClosedRange ` :
309
+
310
+ ``` swift
311
+ extension Optional : Hashable where Wrapped: Hashable { /* ...*/ }
312
+ extension Array : Hashable where Element : Hashable { /* ...*/ }
313
+ extension ArraySlice : Hashable where Element : Hashable { /* ...*/ }
314
+ extension ContiguousArray : Hashable where Element : Hashable { /* ...*/ }
315
+ extension Dictionary : Hashable where Value : Hashable { /* ...*/ }
316
+ extension Range : Hashable where Bound: Hashable { /* ...*/ }
317
+ extension ClosedRange : Hashable where Bound: Hashable { /* ...*/ }
318
+ ```
319
+
320
+ While the standard library did not previously provide existing
321
+ implementations of ` hashValue ` for these types, conditional ` Hashable `
322
+ conformance is a natural expectation for them.
323
+
324
+ Note that ` Set ` is already (unconditionally) ` Equatable ` and ` Hashable ` .
308
325
309
326
In addition, it is intended that the standard library adopt conditional conformance
310
327
to collapse a number of "variants" of base types where other generic parameters
You can’t perform that action at this time.
0 commit comments