Skip to content

Conversation

@tarcieri
Copy link
Member

Introduces a set of helper traits for the following:

  • CtAssign: CtAssignSlice
  • CtEq: CtEqSlice
  • CtSelect: CtSelectArray

Implementing a *Slice trait unlocks a blanket impl for the corresponding trait for [T], e.g. impl'ing CtAssignSlice for T means CtAssign will now work with [T].

Likewise, implementing CtSelectArray unlocks the blanket impl of CtSelect for [T; N], and CtSelectArray itself is already blanket impl'd for types which impl Clone + CtAssignSlice + CtSelect.

All traits provide a default implementation with the option to plug in a faster one. The implementations on core integers thunk to the corresponding Cmov/CmovEq impls on slices of core integers, which in some cases have been optimized (especially u8).

Introduces a set of helper traits for the following:

- `CtAssign`: `CtAssignSlice`
- `CtEq`: `CtEqSlice`
- `CtSelect`: `CtSelectArray`

Implementing a `*Slice` trait unlocks a blanket impl for the
corresponding trait for `[T]`, e.g. impl'ing `CtAssignSlice` for `T`
means `CtAssign` will now work with `[T]`.

Likewise, implementing `CtSelectArray` unlocks the blanket impl of
`CtSelect` for `[T; N]`, and `CtSelectArray` itself is already blanket
impl'd for types which impl `Clone + CtAssignSlice + CtSelect`.

All traits provide a default implementation with the option to plug in a
faster one. The implementations on core integers thunk to the
corresponding `Cmov`/`CmovEq` impls on slices of core integers, which
in some cases have been optimized (especially `u8`).
@tarcieri tarcieri merged commit b5d28ce into master Jan 18, 2026
12 checks passed
@tarcieri tarcieri deleted the ctutils/pluggable-array-and-slice-impls branch January 18, 2026 03:55
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