title: Why do I get the error "expected type argument" when I annotate a type in a Rust function?
body: <p>I am playing around with Rust's <a href="https://github.com/dwrensha/capnproto-rust" rel="nofollow noreferrer">capnproto library</a>. Because Rust can infer types in some situations, I can do things like this:</p>
  
  <pre><code>let mut message = ::capnp::message::Builder::new_default();
  </code></pre>
  
  <p>Without having to know the type of message. If I want to pass a reference to <code>message</code> into a function, I now need to know what message is to let the function know what to expect.</p>
  
  <p>Is there a convenient way to do this in general?</p>
  
  <p>So far I have done the following:</p>
  
  <pre><code>let testing: () = message;
  </code></pre>
  
  <p>which fails with the compiler error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
     --&gt; src/main.rs:197:18
      |
  197 |                 let temp: () = message;
      |                           ^^^^^^^ expected (), found struct `capnp::message::Builder`
  </code></pre>
  
  <p>But when I type annotate my function as follows:</p>
  
  <pre><code>fn example_fn(message: capnp::message::Builder) {...}
  </code></pre>
  
  <p>I get an error like:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0243]: wrong number of type arguments: expected 1, found 0
    --&gt; src/main.rs:72:32
     |
  72 | fn dump_capnp_to_file(message: capnp::message::Builder, filename: &amp;str) {
     |                                ^^^^^^^^^^^^^^^^^^^^^^^ expected 1 type argument
  </code></pre>
  
  <p>error: aborting due to previous error</p>
  
  <p>I'm very new to Rust coming from a C++ background; sorry if this a rookie question!</p>