title: Swift: Hashable struct with dictionary property
body: <p>I have a struct in Swift that looks like this:</p>
  
  <pre><code>internal struct MapKey {
      internal let id: String
      internal let values: [String:String]
  }
  extension MapKey: Equatable {}
  func ==(lhs: MapKey, rhs: MapKey) -&gt; Bool {
      return lhs.id == rhs.id &amp;&amp; lhs.values == rhs.values
  }
  </code></pre>
  
  <p>I now have the need to use MapKey as the key in a Swift dictionary, which requires MapKey to conform to the Hashable protocol.</p>
  
  <p>What would a correct implementation of Hashable be for a struct like this one? </p>
  
  <pre><code>extension MapKey: Hashable {
      var hashValue: Int {
          return ??? // values does not have a hash function/property.
      }
  }
  </code></pre>
  
  <p>I've been doing some research but failed to identify what the proper way to hash a dictionary is, as I need to be able to generate a hash value for <em>values</em> property itself. Any help is much appreciated.</p>