title: How to fetch associations with Diesel?
body: <p>I'm trying to load an association from a database using Diesel. I have the following models defined:</p>
  <pre class="lang-rust prettyprint-override"><code>#[derive(Identifiable, Queryable, PartialEq, Debug)]
  #[table_name = &quot;contacts&quot;]
  pub struct Contact {
      pub id: i32,
      pub firstname: String,
      pub lastname: String,
  }
  
  #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
  #[belongs_to(Contact)]
  #[table_name = &quot;emails&quot;]
  pub struct Email {
      pub id: i32, 
      pub contact_id: i32,
      pub label: String,
      pub email: String,
  }
  </code></pre>
  <p>Now I'm trying to fetch all contacts with their associated emails using the following code:</p>
  <pre class="lang-rust prettyprint-override"><code>let result = match contacts::table
      .inner_join(emails::table)
      .load::&lt;models::Contact, Vec&lt;models::Email&gt;&gt;(&amp;self.conn)
  {
      Ok(rows) =&gt; rows,
      Err(_) =&gt; return Err(io::Error::new(io::ErrorKind::Other, &quot;Database error&quot;)),
  };
  </code></pre>
  <p>But this is not working. The error is something about a trait bound that is not satisfied:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0107]: wrong number of type arguments: expected 1, found 2
    --&gt; src/db.rs:44:38
     |
  44 |             .load::&lt;models::Contact, Vec&lt;models::Email&gt;&gt;(&amp;self.conn) {
     |                                      ^^^^^^^^^^^^^^^^^^ unexpected type argument
  
  error[E0277]: the trait bound `(i32, std::string::String, std::string::String): diesel::Queryable&lt;((diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text), (diesel::sql_types::Integer, diesel::sql_types::Nullable&lt;diesel::sql_types::Integer&gt;, diesel::sql_types::Text, diesel::sql_types::Text)), _&gt;` is not satisfied
    --&gt; src/db.rs:44:14
     |
  44 |             .load::&lt;models::Contact, Vec&lt;models::Email&gt;&gt;(&amp;self.conn) {
     |              ^^^^ the trait `diesel::Queryable&lt;((diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text), (diesel::sql_types::Integer, diesel::sql_types::Nullable&lt;diesel::sql_types::Integer&gt;, diesel::sql_types::Text, diesel::sql_types::Text)), _&gt;` is not implemented for `(i32, std::string::String, std::string::String)`
     |
     = help: the following implementations were found:
               &lt;(A, B, C) as diesel::Queryable&lt;(SA, SB, SC), __DB&gt;&gt;
               &lt;(A, B, C) as diesel::Queryable&lt;diesel::sql_types::Record&lt;(SA, SB, SC)&gt;, diesel::pg::Pg&gt;&gt;
     = note: required because of the requirements on the impl of `diesel::Queryable&lt;((diesel::sql_types::Integer, diesel::sql_types::Text, diesel::sql_types::Text), (diesel::sql_types::Integer, diesel::sql_types::Nullable&lt;diesel::sql_types::Integer&gt;, diesel::sql_types::Text, diesel::sql_types::Text)), _&gt;` for `models::Contact`
     = note: required because of the requirements on the impl of `diesel::query_dsl::LoadQuery&lt;_, models::Contact&gt;` for `diesel::query_builder::SelectStatement&lt;diesel::query_source::joins::JoinOn&lt;diesel::query_source::joins::Join&lt;schema::contacts::table, schema::emails::table, diesel::query_source::joins::Inner&gt;, diesel::expression::operators::Eq&lt;diesel::expression::nullable::Nullable&lt;schema::emails::columns::contact_id&gt;, diesel::expression::nullable::Nullable&lt;schema::contacts::columns::id&gt;&gt;&gt;&gt;`
  </code></pre>
  <p>What am I missing?</p>