Currently, my code looks like this:
struct Node<T>: Hashable
where T: Equatable, T: Hashable {
....
}
Is there a more easy notation to write the same thing? Thanks!
Jumhyn
(Frederick Kellison-Linn)
2
Hashable refines Equatable so your constraint can just be where T: Hashable—or were you looking for a syntax for the general struct S<T>: P where T: P construct for arbitrary P?
Thanks,
I was looking for what is the syntax for specifying two constraints on the same type more concisely than repeating the type.
xAlien95
(Stefano De Carolis)
4
You can use T: P & Q to avoid repetition.
4 Likes
mayoff
(Rob Mayoff)
5
struct Node<T: Hashable>: Hashable {
...
3 Likes