title: How do I make my own adapter methods able to consume a trait object?
body: <p>I have a trait that has "adapter methods" that consume the method:</p>
  
  <pre><code>struct Bar&lt;T&gt;(T);
  
  trait Foo {
      fn make_bar(self) -&gt; Bar&lt;Self&gt;
      where
          Self: Sized,
      {
          Bar(self)
      }
  }
  
  impl Foo for u8 {}
  impl Foo for bool {}
  </code></pre>
  
  <p>This is modeled after <code>Iterator</code>. When I use a <code>Box&lt;Iterator&gt;</code>, I can still call <code>Iterator</code> adapter methods like <code>map</code> or <code>filter</code>:</p>
  
  <pre><code>fn main() {
      let a = vec![1, 2, 3];
      let b: Box&lt;Iterator&lt;Item = u8&gt;&gt; = Box::new(a.into_iter());
      let c = b.map(|x| x * 2);
      for z in c {
          println!("{}", z)
      }
  }
  </code></pre>
  
  <p>However, the methods I've defined don't work in the same way:</p>
  
  <pre><code>fn main() {
      let a: Box&lt;Foo&gt; = Box::new(42);
      a.make_bar();
  }
  </code></pre>
  
  <p>This fails with the errors</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `Foo: std::marker::Sized` is not satisfied
    --&gt; src/main.rs:18:7
     |
  18 |     a.make_bar();
     |       ^^^^^^^^ `Foo` does not have a constant size known at compile-time
     |
     = help: the trait `std::marker::Sized` is not implemented for `Foo`
  </code></pre>
  
  <p>It's absolutely correct that <code>Foo</code> does not have a size - it's a trait. However, <code>Box&lt;Foo&gt;</code> <em>should</em> have a size, as I understand it. What is <code>Iterator</code> doing differently from my code?</p>