std.bigint: support construction from Int128#10948
Conversation
Fixes issue 10945.
|
Thanks for your pull request and interest in making D better, @Prashant-900! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
|
You'd likely need an |
|
Added assignment from Int128 and unit tests for a sanity check. While doing so, I noticed an inconsistency: This works, but: does not. Assigning an int to Int128 also fails. Is this expected behavior, or should this be raised as an issue? |
Removed an unnecessary blank line before the constructor.
|
@ibuclaw Do you consider the added unittests to be sufficient? |
| /// Construct `BigInt` from `Int128` | ||
| import std.int128 : Int128; |
There was a problem hiding this comment.
| /// Construct `BigInt` from `Int128` | |
| import std.int128 : Int128; | |
| import std.int128 : Int128; | |
| /// Construct `BigInt` from `Int128` |
Not sure if this is needed, but I think the doc comment should be after the import.
| } | ||
|
|
||
| /// Construct `BigInt` from `Int128` | ||
| import std.int128 : Int128; |
There was a problem hiding this comment.
Putting this import here means that it will be affected by the public: attribute specifier on line 53, turning it into a public import. This means that the symbol Int128 will be visible as BigInt.Int128 from outside the std.bigint module.
To fix this, move the import to the top of the module, outside the declaration of struct BigInt.
This PR adds explicit BigInt constructors for Int128 resolving issue #10945.