neqo icon indicating copy to clipboard operation
neqo copied to clipboard

Should we have a saturating shift function?

Open larseggert opened this issue 10 months ago • 4 comments

This seems good. Should we have a saturating shift function? This isn't the first time we've needed this sort of thing.

Originally posted by @martinthomson in https://github.com/mozilla/neqo/pull/2294#discussion_r1938445973

larseggert avatar Feb 02 '25 12:02 larseggert

Until https://doc.rust-lang.org/beta/std/num/struct.Saturating.html#method.rotate_left is stable, we might as well just copy the implementation.

mxinden avatar Feb 02 '25 14:02 mxinden

Rotation isn't what we want. The code we'd need is here: https://doc.rust-lang.org/beta/src/core/num/saturating.rs.html#82 (commented out with a big question about what it means). Perhaps we can provide some useful input to that discussion.

martinthomson avatar Feb 02 '25 21:02 martinthomson

I've commented on https://github.com/rust-lang/rust/issues/103440, which covers the language enhancements.

martinthomson avatar Feb 03 '25 00:02 martinthomson

I think there is only check_blocked_streams where we'd use this. Not sure if it is worth it.

larseggert avatar Sep 29 '25 13:09 larseggert