title: Rust Error: The size for values of type `(dyn std::error::Error + 'static)` cannot be known at compilation time
body: <p>first of all I want to mention that there many similar question on StackOverflow and around the web but I just can't figure out how to solve this error for my case.</p>
  
  <p>So I have a struct, which represents my own error type:</p>
  
  <pre><code>#[derive(Debug)]
  pub struct Error {
      msg: String,
  }
  </code></pre>
  
  <p>Then I continued implementing <code>Display</code> and <code>std::error::Error</code> for my error type:</p>
  
  <pre><code>impl Display for Error {
      fn fmt(&amp;self, f: &amp;mut fmt::Formatter) -&gt; fmt::Result {
          write!(f, "{}", self.msg)
      }
  }
  
  impl std::error::Error for Error {
      fn description(&amp;self) -&gt; &amp;str {
          &amp;self.msg
      }
  }
  </code></pre>
  
  <p>Now I tried to implement <code>std::convert::From</code> so I can use my error type  seamlessly with the <code>?</code> operator:</p>
  
  <pre><code>impl From&lt;dyn std::error::Error&gt; for Error {
      fn from(err: dyn std::error::Error) -&gt; Self {
          Error {
              msg: err.to_string(),
          }
      }
  }
  </code></pre>
  
  <p>But then the rust-compiler gives me this error:</p>
  
  <pre><code>error[E0277]: the size for values of type `(dyn std::error::Error + 'static)` cannot be known
  at compilation time
    --&gt; wasm_api/geohub_wasm_filehandler_api/src/lib.rs:33:6
     |
  33 | impl From&lt;dyn std::error::Error&gt; for Error {
     |      ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
     |
  </code></pre>
  
  <p>I know that by default, generic functions will work only on types that have a known size at compile time. But I cant figure out how to solve this problem properly.</p>
  
  <p>Thanks for your help!</p>
  
  <p><strong>Link to code on Rust-Playground:</strong></p>
  
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=568900e8c7847c1f79781fa9bb6d499d" rel="noreferrer">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=568900e8c7847c1f79781fa9bb6d499d</a></p>