Brought this up on IRC the other day and was told to make an issue :) The current syntax for Pow() is confusing/inconsistent for (ignorant) newcomers like myself. For floats, you can do: ``` rust let my_float = 5f32; let pow2 = my_float.pow(2); ``` But for any of the integers, you need to use the "static" trait function since integers do not implement the Algebraic trait: ``` rust let my_int = 5u32; let pow2 = Int::pow(my_int, 2); ```
Activity
bluss commentedon Sep 28, 2013
Just a correction, the syntax for the float case has to be one of:
lilac commentedon Jan 22, 2014
As in the current master branch, there are three pow variants:
All of them are plain functions, so
5.0f.pow(&2.0)
doesn't work now.Can this issue be closed then?
huonw commentedon Jan 22, 2014
There's actually more than three version of "power", and
5.0.pow(&2.0)
was replaced with.powf
.In any case, I think the
f32
andf64
freestandingpow
's should be removed or made private (if possible).frewsxcv commentedon Jan 24, 2015
A quick update: a
pow()
method was added to theInt
trait in this pull request, despite it not existing in the numerics reform RFCsteveklabnik commentedon Feb 15, 2015
This is now all consistent, as far as I can tell.
Int
haspow
, andFloat
's was changed topowi
andpowf
, but the method syntax works.Auto merge of rust-lang#9592 - c410-f3r:arith, r=Jarcho