bnum icon indicating copy to clipboard operation
bnum copied to clipboard

Const casting between bnum types

Open darsor opened this issue 2 months ago • 2 comments

Many of the functions in the crate are const, which is much appreciated. But I can not find a const way to cast between bnum types (for example, from a U1024 to a I256. Obviously the trait-based casting (As), which appears to be the primary approach, can't be const.

Does this feature already exist, and if not, can it be added?

darsor avatar Oct 29 '25 13:10 darsor

Hi @darsor, right now bnum doesn't provide const casting functionality, for now you'd have to implement it yourself by copying the logic from the trait-based casting. However, when the next version is released, it will be much easier to perform const casting. I will comment with an update once this has been published.

isaacholt100 avatar Nov 02 '25 18:11 isaacholt100

Thanks for the quick response. I'll try copying the trait-based casting logic for now.

darsor avatar Nov 04 '25 03:11 darsor