title: Pass any Diesel table as an argument
body: <p>I have Rust project with Diesel implemented and it generated schema.rs file which contains all of my tables:</p>
  <pre class="lang-rust prettyprint-override"><code>table! {
      users (id) {
          id -&gt; Uuid,
          name -&gt; Varchar,
      }
  }
  
  table! {
      items (id) {
          id -&gt; Uuid,
          name -&gt; Varchar,
      }
  }
  </code></pre>
  <p>How could I pass any table as an argument inside of my utility function?
  For instance,</p>
  <pre class="lang-rust prettyprint-override"><code>pub trait Search {
      fn internal_get_by_id(
          diesel_table: diesel::table, // this argument should pass any diesel table
          table_id: diesel::table::id, // this argument should pass Uuid from table
          conn: &amp;Conn,
          id: Uuid,
      ) -&gt; Fallible&lt;Option&lt;Self&gt;&gt;
      where
          Self: Sized,
      {
          diesel_table
              .filter(table_id.eq(id))
              .first(conn.raw())
              .optional()
              .map_err(Error::from)
      }
  
      fn get_by_id(conn: &amp;Conn, id: Uuid) -&gt; Fallible&lt;Option&lt;Self&gt;&gt;
      where
          Self: Sized;
  }
  
  impl Search for User {
      fn get_by_id(conn: &amp;Conn, id: Uuid) -&gt; Fallible&lt;Option&lt;User&gt;&gt; {
          Self::internal_get_by_id(users::table, users::id, conn, id)
      }
  }
  
  impl Search for Item {
      fn get_by_id(conn: &amp;Conn, id: Uuid) -&gt; Fallible&lt;Option&lt;Item&gt;&gt; {
          Self::internal_get_by_id(items::table, items::id, conn, id)
      }
  }
  </code></pre>