title: Swift guard statement pattern matching with enum
body: <p>I'm trying to return the head element of my own implementation of a Doubly Linked List in Swift.
  My Nodes are declared as an enum like this:</p>
  
  <pre><code>enum DLLNode&lt;Element&gt;{
      indirect case Head(element: Element, next: DLLNode&lt;Element&gt;)
      indirect case Node(prev: DLLNode&lt;Element&gt;, element: Element, next: DLLNode&lt;Element&gt;)
      indirect case Tail(prev: DLLNode&lt;Element&gt;, element: Element)
  }
  </code></pre>
  
  <p>and the list implementation like this:</p>
  
  <pre><code>struct DLList&lt;Element&gt; {
      var head:DLLNode&lt;Element&gt;?
  
  ...
  
  func getFirst()throws-&gt;Element{
          if self.isEmpty(){
              throw ListError.EmptyList(msg: "")
          }
          guard case let DLLNode&lt;Element&gt;.Head(element: e, next: _) = head
              else{
                  throw ListError.UnknownError(msg: "")
          }
          return e
      }
  }
  </code></pre>
  
  <p>But I'm getting <code>"Invalid pattern"</code> on the guard statement. If I omit the <code>DLLNode&lt;Element&gt;</code> and just keep it like <code>guard case let .Head(element: e, next: _) = head</code> it gives me <code>"Enum case 'Head' not found in 'guard case let DLLNode&lt;Element&gt;.Head(element: e, next: _) = head'"</code>
  What am I doing wrong? Or maybe there is a better way to do this?</p>