speedy icon indicating copy to clipboard operation
speedy copied to clipboard

Please fix: lengths encoding, fixed-size arrays and references

Open seniorjoinu opened this issue 2 years ago • 1 comments

  1. T::minimum_bytes_needed() for some types returns hardcoded values, instead of values based on size_of::<T>(), which leads to errors on 64-bits machines. For example, encoding a BTreeSet with more than 2**32 elements won't work properly.

  2. Now Readable and Writable are only implemented for fixed-size arrays up to 16. Please use generic const expressions and implement them for any size array.

  3. Readable and Writable are not implemented for &[u8] and similar types which is a shame.

Please, consider fixing these issues. If you need a PR, I can provide you with one.

seniorjoinu avatar Oct 16 '22 17:10 seniorjoinu

The first point is a feature, not a bug. If you need to store more than 2^32 elements you can always use the length_type attribute or create a newtype. Besides, we can't really change this without breaking backwards compatibility even if we wanted to as the serialization format is stable and will not change.

Points (2) and (3) are indeed reasonable and could indeed be fixed.

koute avatar Oct 28 '22 10:10 koute