title: Generic functions that take structs with
body: <p>I am trying to write a generic function. I have the following code:</p>
  <pre><code>struct Car {
      id: u8,
      wheels: u8,
      seatbelt: bool,
  }
  
  struct Motorcycle {
      id: u8,
      wheels: u8,
      helmet: bool,
  
  trait Vehicle {}
  impl Vehicle for Car {}
  impl Vehicle for Motorcycle {}
  
  fn vehicle_info&lt;T&gt;(vehicle: T) 
  where
      T: Vehicle,
  {
      println!(&quot;{} {}&quot;, vehicle.id, vehicle.wheels)
  }
  </code></pre>
  <p>The compiler gives me <code>error: no field id on type T.</code>
  Now the question is how do I promise to the compiler in the trait that all structs passed into the function have these certain fields?</p>