Skip to content

Pow() syntax is inconsistent between floats and ints #9592

@polyfractal

Description

@polyfractal

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:

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:

let my_int = 5u32;
let pow2 = Int::pow(my_int, 2);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions