Closed casey closed 3 weeks ago
I enabled these denies a while back:
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_sign_loss,
That doesn't completely ban as
, but it seems like it avoids the problematic uses. Are there additional cases you see?
I assume this is fixed by https://github.com/cberner/redb/pull/886
Yah I think that got rid of all the problematic uses.
I think that since there are so many tricky integer conversions,
as
casts should be linted for and denied throughout the codebase.I didn't see any in particular, but they're so fickle that I think they're worth avoiding entirely, so you don't even have to think about whether or not an individual instance is correct.
One thing you can do to make this easier is to add a trait like this:
And then implement it for all types smaller or equal to than minimum
usize
that redb supports. So since I thinkredb
can only run on 32-bit-or-better systems,u8
,u16
, andu32
could all implementIntoUsize
, which would get rid of a ton of the remainingas
conversions.