Home > OS >  How do I discover which trait from_str_radix() belongs to?
How do I discover which trait from_str_radix() belongs to?

Time:01-18

I want to use from_str_radix() in a generic function.

This function is implemented in a macro.

I successfully use the bound T: std::str::FromStr to give me str::parse::<T> but I do not know how to find out which trait from_str_radix() belongs to.

What is the method, for finding out which trait an arbitrary function (implemented across many integer types) belongs to?

CodePudding user response:

It does not belong to any trait.

If you need it in a trait for a generic bound, you can use num_traits::Num.

  • Related