title: Why can you only specify type restrictions with traits?
body: <p>In Rust you can only use traits to specify type restrictions, for example: <code>&lt;T: A + B&gt;</code>, A and B must be traits, they cannot be primitive types like <code>i32</code> or <code>f64</code>.</p>
  
  <pre><code>trait Foo {}
  
  impl Foo for i32 {}
  
  fn blah&lt;T: i32&gt;(val: T) {
      //     ^^^ works if this is Foo
      println!("hello\n");
  }
  
  fn main() {
      let toast: i32 = 33;
      blah(toast);
  }
  </code></pre>
  
  <p>You can get around this by implementing a trait <em>for</em> a primitive, but why would the designers of the language not let you use primitives as a restriction?</p>