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

Add missing TryFrom impls #1870

Merged
merged 11 commits into from
Sep 19, 2023
Merged

Add missing TryFrom impls #1870

merged 11 commits into from
Sep 19, 2023

Conversation

chipshort
Copy link
Collaborator

@chipshort chipshort commented Sep 11, 2023

closes #1863

I also ended up adding the rest of the missing unsigned to signed TryFrom impls and signed to unsigned TryFrom impls because I needed some more for the SignedDecimal PR:

  • Uint{64,128,256,512} -> Int64
  • Uint{128,256,512} -> Int128
  • Uint{256, 512} -> Int256
  • Uint512 -> Int512
  • Int{64,128,256,512} -> Uint{64,128,256,512}

@chipshort chipshort changed the title Add missing TryFrom impls for Uint64 Add missing TryFrom impls Sep 13, 2023
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Just a CHANGELOG and then this is good to go

@@ -270,12 +271,24 @@ impl Int128 {
}
}

impl NumConsts for Int128 {
const ZERO: Self = Self::zero();
const ONE: Self = Self::one();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why zero() and one() are functions and not consts? Should this be changed for the public interface too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why those are functions. I think using constants is more common, but it doesn't really make a difference. As far as I know, they can be used interchangeably.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the standard library types don't have zero and one. So it does not matter much I guess.

@chipshort chipshort merged commit 0425abf into main Sep 19, 2023
3 checks passed
@chipshort chipshort deleted the 1863-missing-tryfrom branch September 19, 2023 07:44
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.

Add missing unsigned int TryFrom implementations
2 participants