Generics in Extension of Array of ClosedRange

Hi there!
I'm trying to make Array extension where Element is ClosedRange where T:Comparable. But it seems to be impossible.

extension Array where Element == ClosedRange<Element.Bound> {

causes an error: Same-type constraint 'Element' == 'ClosedRange<Element.Bound>' is recursive

I tried few ways to solve this puzzle, but with no success.
I found it interesting, it's why I post it here.

I believe you have to put the where clause on the method itself, rather than the extension block:

extension Array {
  func foo<Bound>() where Element == ClosedRange<Bound> {
    …
  }
}
2 Likes

Yea, this is an idea. For some (idiotic?) reasons I tried to avoid it. Thanx!