0

I can not find a built-in function to check the type of my param in this function (Rust):

pub fn notify<T: Summary + Display>(item: &T) {
    // type of "item" (Summary || Display)
}
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
  • 3
    You generally can't. This is probably an [XY problem](https://xyproblem.info/). Perhaps you should edit your question to describe _why_ you want to do this, and we can suggest alternatives. – cdhowie Jun 23 '22 at 10:38
  • What do you mean, check the type? The compiler will make sure that `item` is both `Summary` **and** `Display`. – Sergio Tulentsev Jun 23 '22 at 10:44
  • Also, by that `Summary || Display`, I think that you think `T: Summary+Display` means `T: Summary` or `T: Display`, whereas it's `T: Summary` **and** `T: Display`. – jthulhu Jun 23 '22 at 11:09

0 Answers0