tsethash.nim 416 B

12345678910111213141516171819202122232425
  1. # issue #14729
  2. import sets, hashes
  3. type
  4. Iterable[T] = concept x
  5. for value in items(x):
  6. type(value) is T
  7. Foo[T] = object
  8. t: T
  9. proc myToSet[T](keys: Iterable[T]): HashSet[T] =
  10. for x in items(keys): result.incl(x)
  11. proc hash[T](foo: Foo[T]): Hash =
  12. echo "specific hash"
  13. proc `==`[T](lhs, rhs: Foo[T]): bool =
  14. echo "specific equals"
  15. let
  16. f = Foo[string](t: "test")
  17. hs = [f, f].myToSet()