Skip to content

Conversation

@tarcieri
Copy link
Member

Adds a set of Choice constructors following the same pattern we already implement for u32, u64, and u128.

Interestingly, this gives us an alternative to Choice::new which doesn't have to deal with out-of-range values: Choice::from_u8_lsb. With that possibility noted, this also documents Choice::new may be deprecated in the future. Ideally it could be removed before final crypto-bigint releases.

Regarding u16, I actually ran into a real-world case where this would've been helpful inside crypto-bigint.

Adds a set of `Choice` constructors following the same pattern we
already implement for `u32`, `u64`, and `u128`.

Interestingly, this gives us an alternative to `Choice::new` which
doesn't have to deal with out-of-range values: `Choice::from_u8_lsb`.
With that possibility noted, this also documents `Choice::new` may be
deprecated in the future. Ideally it could be removed before final
`crypto-bigint` releases.

Regarding `u16`, I actually ran into a real-world case where this
would've been helpful inside `crypto-bigint`.
@tarcieri tarcieri merged commit 7746d38 into master Dec 29, 2025
13 checks passed
@tarcieri tarcieri deleted the ctutils/choice-from-u8-and-u16 branch December 29, 2025 17:20
@tarcieri tarcieri mentioned this pull request Dec 29, 2025
tarcieri added a commit that referenced this pull request Dec 29, 2025
### Added
- Impl `From<u8>` for `Choice` (#1309)
- `Choice::from_u8*` and `from_u16*` (#1311)

### Changed
- Deprecate `Choice::new` (#1312)
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