title: How do I check if a trait is implemented at compile time in Rust?
body: <p>I want to print a variable with the <code>Display</code> trait if it is implemented, or with the <code>Debug</code> trait otherwise. All the types are known at compile time.</p>
  
  <pre><code>let display = MyDisplayType::new(); // implements Display
  let debug = MyDebugType::new(); // implements Debug
  
  output!(display); // uses Display a.k.a. println!("{}", display);
  output!(debug); // uses Debug a.k.a. println!("{:?}", debug);
  </code></pre>
  
  <p>What is the cleanest way?</p>