Skip to content

Conversation

@tarcieri
Copy link
Member

Note: version bumped to v0.4.0-pre to denote breaking change (not for release)

Extracts the ct_assign method into its own trait. The main advantage of this is the CtSelect trait requires a Sized bound, where an independent CtAssign trait does not, which means it can be impl'd for slices as a sort of conditional copy_from_slice.

The main disadvantage is we lose the default implementation, so it becomes one more trait to impl. There's no good way to blanket impl one in terms of the other that won't preclude efficient implementations in some way or another, so this opts not to do that for maximum flexibility.

To preserve subtle-like ergonomics where CtSelect means we can CtAssign as well, this bounds CtSelect on CtAssign.

Finally, the same treatment is given to the Bytes* traits, with a BytesCtAssign split out of BytesCtSelect for parity, and an impl of BytesCtAssign for [u8] has been added.

Note: version bumped to v0.4.0-pre to denote breaking change (not for
release)

Extracts the `ct_assign` method into its own trait. The main advantage
of this is the `CtSelect` trait requires a `Sized` bound, where an
independent `CtAssign` trait does not, which means it can be impl'd for
slices as a sort of conditional `copy_from_slice`.

The main disadvantage is we lose the default implementation, so it
becomes one more trait to impl. There's no good way to blanket impl one
in terms of the other that won't preclude efficient implementations in
some way or another, so this opts not to do that for maximum
flexibility.

To preserve `subtle`-like ergonomics where `CtSelect` means we can
`CtAssign` as well, this bounds `CtSelect` on `CtAssign`.

Finally, the same treatment is given to the `Bytes*` traits, with a
`BytesCtAssign` split out of `BytesCtSelect` for parity, and an impl of
`BytesCtAssign` for `[u8]` has been added.
@tarcieri tarcieri merged commit 450a85b into master Jan 16, 2026
117 checks passed
@tarcieri tarcieri deleted the ctutils/split-ctassign-out-of-ctselect branch January 16, 2026 22:37
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