title: How does Rust know which trait methods are required or provided?
body: <p>From the <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next" rel="nofollow noreferrer"><code>std::iter::Iterator</code></a> documentation, I can see that only the <code>next</code> method is required:  </p>
  
  <blockquote>
    <p>Required Methods</p>
  
  <pre><code>fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt;
  </code></pre>
  </blockquote>
  
  <p>But from the <a href="https://doc.rust-lang.org/src/core/iter/iterator.rs.html#31-2165" rel="nofollow noreferrer">source code</a>, after removing comments:  </p>
  
  <pre><code>pub trait Iterator {
      /// The type of the elements being iterated over.
      #[stable(feature = "rust1", since = "1.0.0")]
      type Item;
      ......
      #[stable(feature = "rust1", since = "1.0.0")]
      fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt;;
      ......
      #[inline]
      #[stable(feature = "rust1", since = "1.0.0")]
      fn size_hint(&amp;self) -&gt; (usize, Option&lt;usize&gt;) { (0, None) }
      ......
  }
  </code></pre>
  
  <p>I can see, except for the <code>#[inline]</code> attribute, there is no difference between required and provided methods. How does Rust know which method is required or provided?</p>