Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces the free-standing functions in f32, &c. #7090

Closed
wants to merge 1 commit into from

Conversation

auroranockert
Copy link
Contributor

The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

This means that instead of having to know everywhere what the type is, like

f64::sin(x)

You can simply write code that uses the type-generic versions in num instead, this works for all types that implement the corresponding trait in num.

num::sin(x)

Note 1: If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note 2: If you were using a function that corresponds to an operator, use the
operator instead.

The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note: If you were using a function that corresponds to an operator, use the
operator instead.
@brendanzab
Copy link
Member

looks good!

@Casorati
Copy link

This looks nice, thanks for all the work.
I'm reviewing the code. I have found one thing I don't like, that is
#[inline(always)] pub fn abs<T: Signed>(value: T) -> T { value.abs() }
I don't like it because,

  1. abs can as well be defined for unsigned number as the identity.
  2. abs is usually understood to be the L2 norm and is defined for normed vector space and we probably want to define it for complex numbers although they are not "Signed".

@brendanzab
Copy link
Member

@Casorati would you be able to move this discussion to #4819? This is where most of the discussion about the numeric traits has been going on.

osaut pushed a commit to osaut/rust that referenced this pull request Oct 31, 2013
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

This means that instead of having to know everywhere what the type is, like

~~~
f64::sin(x)
~~~

You can simply write code that uses the type-generic versions in num instead, this works for all types that implement the corresponding trait in num.

~~~
num::sin(x)
~~~

Note 1: If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note 2: If you were using a function that corresponds to an operator, use the
operator instead.

Note 3: This is just rust-lang#7090 reopened against master.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 22, 2021
…hearth

Add a note for pre-expansion passes

changelog: none

Just had to turn away a PR for using pre-expansion. I don't think that was the first time. So hopefully this will inform people sooner.

r? flip1995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants