title: What does the 'where' clause within a trait do?
body: <p>If I have this code:</p>
  
  <pre><code>trait Trait {
      fn f(&amp;self) -&gt; i32 where Self: Sized;
  
      fn g(&amp;self) -&gt; i32;
  }
  
  
  fn object_safety_dynamic(x: &amp;Trait) {
      x.f();    // error 
      x.g();    // works
  }
  </code></pre>
  
  <p>What does the <code>where</code> clause actually do? </p>
  
  <p>Naively, I was thinking <code>where Self: Sized;</code> dictates something about the type implementing <code>Trait</code>, like 'if you implement <code>Trait</code> for type <code>A</code> your type <code>A</code> must be sized, i.e., it can be <code>i32</code> but not <code>[i32]</code>.</p>
  
  <p>However, such a constraint would rather go as <code>trait Trait: Sized</code> (correct me if I am wrong)?</p>
  
  <p>Now I noticed <code>where Self: Sized;</code> actually determines if I can call <code>f</code> or <code>g</code> from within <code>object_safety_dynamic</code>.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li><p>What happens here behind the scenes? </p></li>
  <li><p>What (in simple English) am I actually telling the compiler by <code>where Self: Sized;</code> that makes <code>g()</code> work but <code>f()</code> not? </p></li>
  <li><p>In particular: Since <code>&amp;self</code> is a reference anyway, what compiled difference exists between <code>f</code> and <code>g</code> for various (sized or unsized) types. Wouldn't it always boil down to something like <code>_vtable_f_or_g(*self) -&gt; i32</code>, regardless of <code>where</code> or if the type is sized or not?</p></li>
  <li><p>Why can I implement Trait for both <code>u8</code> and <code>[u8]</code>. Shouldn't the compiler actually stop me from implementing <code>f()</code> for <code>[u8]</code>, instead of throwing an error at the call site?</p></li>
  </ol>