title: Is there any way to look up in HashSet by only the value the type is hashed on?
body: <p>I have a struct that has, among other data, a unique <code>id</code>:</p>
  
  <pre><code>struct Foo {
      id: u32,
      other_data: u32,
  }
  </code></pre>
  
  <p>I want to use the <code>id</code> as the key and keep it inside of the struct:</p>
  
  <pre><code>use std::collections::HashSet;
  use std::hash::{Hash, Hasher};
  impl PartialEq for Foo {
      fn eq(&amp;self, other: &amp;Foo) -&gt; bool {
          self.id == other.id
      }
  }
  impl Eq for Foo {}
  impl Hash for Foo {
      fn hash&lt;H: Hasher&gt;(&amp;self, state: &amp;mut H) {
          self.id.hash(state);
      }
  }
  </code></pre>
  
  <p>This works:</p>
  
  <pre><code>pub fn bar() {
      let mut baz: HashSet&lt;Foo&gt; = HashSet::new();
      baz.insert(Foo {
          id: 1,
          other_data: 2,
      });
      let other_data = baz.get(&amp;Foo {
          id: 1,
          other_data: 0,
      }).unwrap()
          .other_data;
      println!("other_data: {}", other_data);
  }
  </code></pre>
  
  <p>Is there any way to write <code>baz.get(1).unwrap().other_data;</code> instead of <code>baz.get(&amp;Foo { id: 1, other_data: 0 }).unwrap().other_data;</code>?</p>
  
  <p>An alternative might be a <code>HashMap</code> where the key is contained inside the <code>struct</code>. However, I can't have the <code>id</code> inside the struct and a duplicate <code>id</code> used for the <code>key</code>.</p>