Comparing generic enum with associated type
<p>I have a result enum and error that looks like:</p>

<pre><code>enum Result&lt;T&gt;: Equatable {
  case Success(T)
  case Error(ErrorType)
}

func ==&lt;T&gt;(lhs: Result&lt;T&gt;, rhs: Result&lt;T&gt;) -&gt; Bool {
  var equal: Bool = false
  switch (lhs, rhs) {
  case (.Success, .Success):
    equal = true
  case (.Error, .Error):
    equal = true
  default:
    break
  }
  return equal
}
</code></pre>

<p>RequestError looks like:</p>

<pre><code>enum RequestError: String,
                   ErrorType,
                   Equatable {
  case NoInternet = "NO_INTERNET_ERROR"
  case Unknown = "UNKNOWN_ERROR"
  case ServerError = "SERVER_ERROR"
}

init?(_ error: NSError?) {
  //do init
}

func ==(lhs: RequestError, rhs: RequestError) -&gt; Bool {
  return lhs.rawValue == rhs.rawValue
}
</code></pre>

<p>I am writing a spec with Quick+Nimble for this:</p>

<pre><code>class ResultSpec: QuickSpec {
  override func spec() {

    describe("Result") {

      context("when comparing 2 success results") {

        it("returns true") {
          let equal = Result.Success(5) == Result.Success(5)
          expect(equal).to(beTrue())
        }

      }

      context("when comparing 2 error results") {

        it("returns true") {
          let error = NSError(domain: "", code: 0, userInfo: nil)
          let requestError = RequestError(error)!
          let equal = Result.Error(requestError) == Result.Error(requestError)
          expect(equal).to(beTrue())
        }

      }

    }

  }
}
</code></pre>

<p>The first test which check Success passes. The second one doesn't compile with the error:</p>

<p>Binary operator '==' cannot be applied to two 'Result&lt;_>' operands</p>

<p>on this line:</p>

<pre><code>let equal = Result.Error(requestError) == Result.Error(requestError)
</code></pre>