With the following:
4.pow(2)
I get:
error: no method named `pow` found for type `_` in the current scope
I have to be more explicit about it, e.g.:
4_i32.pow(2)
With floats, I get a similar problem (and solution), where:
4.0.powf(2.0)
Must also be explicit:
4.0_f64.powf(2.0)
I believe this is because the fallback only happens when all the constraints on the literal have been considered (and it finds that there aren't any).
In this case, to know what the type of 4
is, it has to know what pow
is. But pow
is defined separately for each integral type. So to know what pow
you're talking about, it has to know what the type of 4
is. But to know what the type of 4
is... and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With