Skip to content

Conversation

tarcieri
Copy link
Member

The split_mixed method provides a const fn-friendly way to split numbers.

This refactors it to be a method that accepts self as an argument so it can be called as uint.split_mixed() and also exposes it as pub, allowing downstream users to use it in const fn contexts.

A newly added SplitMixed bound typechecks the sizes of the outputs to ensure that they're a valid combination, which is the best we can do absent something like generic_const_exprs.

The `split_mixed` method provides a `const fn`-friendly way to split
numbers.

This refactors it to be a method that accepts `self` as an argument so
it can be called as `uint.split_mixed()` and also exposes it as `pub`,
allowing downstream users to use it in `const fn` contexts.

A newly added `SplitMixed` bound typechecks the sizes of the outputs to
ensure that they're a valid combination, which is the best we can do
absent something like `generic_const_exprs`.
@tarcieri tarcieri merged commit 1595964 into master Jan 16, 2024
@tarcieri tarcieri deleted the uint/split-mixed-accepts-self branch January 16, 2024 18:00
tarcieri added a commit that referenced this pull request Jan 16, 2024
Does a similar treatment to what #556 and #557 did for `split*` methods,
moving `concat_mixed` to be a method on `Uint` that accepts `&self`,
making the method public, and redefining `Uint::concat` generically with
bounds on `Self: Concat`.
tarcieri added a commit that referenced this pull request Jan 16, 2024
Does a similar treatment to what #556 and #557 did for `split*` methods,
moving `concat_mixed` to be a method on `Uint` that accepts `&self`,
making the method public, and redefining `Uint::concat` generically with
bounds on `Self: Concat`.
@tarcieri tarcieri mentioned this pull request Jan 22, 2025
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.

1 participant