I want to print a variable with the Display
trait if it is implemented, or with the Debug
trait otherwise.
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);
What is the cleanest way?
Aucun commentaire:
Enregistrer un commentaire