title: How do I implement Ord for a struct?
body: <p>I've seen a question similar to this one, but no one that tells me exactly how to implement <code>Ord</code> for a struct. For example, the following:</p>
  
  <pre><code>struct SomeNum {
      name: String,
      value: u32,
  }
  
  impl Ord for SomeNum {
      fn cmp(&amp;self, other:&amp;Self) -&gt; Ordering {
          let size1 = self.value;
          let size2 = other.value;
          if size1 &gt; size2 {
              Ordering::Less
          }
          if size1 &lt; size2 {
              Ordering::Greater
          }
          Ordering::Equal
      }
  }
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <pre><code>error: the trait `core::cmp::Eq` is not implemented for the type `SomeNum` [E0277]
  </code></pre>
  
  <p>How would I fix this? I have tried changing the implementation to:</p>
  
  <pre><code>impl Ord for SomeNum where SomeNum: PartialOrd + PartialEq + Eq {...}
  </code></pre>
  
  <p>and adding the appropriate <code>partial_cmp</code> and <code>eq</code> functions but it gives me the error that both those methods are not a member of <code>Ord</code>.</p>