subtle icon indicating copy to clipboard operation
subtle copied to clipboard

add usize/isize to generated trait impls

Open cosmicexplorer opened this issue 2 years ago • 2 comments

It seems like usize and isize could reasonably be allowed to implement ConstantTime{Greater,Less} via the macros that are already used for other integer types. I assumed it was an oversight that this wasn't already done.

cosmicexplorer avatar Dec 31 '22 18:12 cosmicexplorer

See also previous rationale on #83

isislovecruft avatar Feb 27 '23 22:02 isislovecruft

I've encountered a use case for this: when you are using usize as an index, looping over every item of a n-length collection.

In my particular case, it involves computing a value on an entry at a given index, and then selecting whether to store or discard the result based on whether or not the index matches a specified value.

Here's a real-world example: https://github.com/RustCrypto/crypto-bigint/blob/4aee8ce1e185f9c1156a162ecce6164bf80ab915/src/uint/boxed/bits.rs#L40

tarcieri avatar Nov 27 '23 19:11 tarcieri