Skip to content

Use i64, and allow trivial_numeric_casts#7

Merged
bors[bot] merged 3 commits into
rust-num:masterfrom
cuviper:trivial-casts
Jan 23, 2018
Merged

Use i64, and allow trivial_numeric_casts#7
bors[bot] merged 3 commits into
rust-num:masterfrom
cuviper:trivial-casts

Conversation

@cuviper

@cuviper cuviper commented Jan 23, 2018

Copy link
Copy Markdown
Member

The traits are implemented from 64-bit values, and we don't want to lose
any bits when comparing on platforms with smaller isize.

Simple enum expressions may have no explicit type, like A = 1, so then
the derived 1 as i64 is inferred like 1i64 as i64, a trivial numeric
cast. But it's quite possible that other expressions could have explicit
types, so we can't just assign it directly either. The simple solution is
to just allow the trivial_numeric_casts in derived code.

Fixes #6.

The traits are implemented from 64-bit values, and we don't want to
lose any bits when comparing on platforms with smaller `isize`.
Simple enum expressions may have no explicit type, like `A = 1`, so then
the derived `1 as i64` is inferred like `1i64 as i64`, a trivial numeric
cast.  But it's quite possible that other expressions could have
explicit types, so we can't just assign it directly either.  The simple
solution is to just allow the `trivial_numeric_casts` in derived code.
@Pzixel

Pzixel commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

great job!

@cuviper

cuviper commented Jan 23, 2018

Copy link
Copy Markdown
Member Author

Thanks for checking it!

bors r+

bors Bot added a commit that referenced this pull request Jan 23, 2018
7: Use i64, and allow trivial_numeric_casts r=cuviper a=cuviper

The traits are implemented from 64-bit values, and we don't want to lose
any bits when comparing on platforms with smaller `isize`.

Simple enum expressions may have no explicit type, like `A = 1`, so then
the derived `1 as i64` is inferred like `1i64 as i64`, a trivial numeric
cast.  But it's quite possible that other expressions could have explicit
types, so we can't just assign it directly either.  The simple solution is
to just allow the `trivial_numeric_casts` in derived code.

Fixes #6.
@Pzixel

Pzixel commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

Wait, I didn't check it yet :) Going to do it now.

Yep, it does! 🎉

@bors

bors Bot commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

Build succeeded

@bors bors Bot merged commit c833a9e into rust-num:master Jan 23, 2018
@cuviper

cuviper commented Jan 23, 2018

Copy link
Copy Markdown
Member Author

Oops. :) I'll wait for you before I publish anything...

@Pzixel

Pzixel commented Jan 23, 2018

Copy link
Copy Markdown
Contributor

@cuviper see edit :) I actually was going to sleep, but your response has waken me up 😄

P.S. Shouldn't we update version?

@cuviper

cuviper commented Jan 23, 2018

Copy link
Copy Markdown
Member Author

(quietly) num-traits 0.1.43 is published -- good night!

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.

2 participants