m4b / scroll

Scroll - making scrolling through buffers fun since 2016
MIT License
155 stars 37 forks source link

usize/isize impls must die #64

Closed m4b closed 4 years ago

m4b commented 5 years ago

It's a breaking change but I am very strongly inclined to remove them in next release.

Reasons:

  1. one can accidentally pass usize to pwrite and it writes an 8 byte number (if you're on 64-bit machine), i.e., something coming from len()`, when you actually meant to write a u32 (but forgot to cast). This has happened several times to me, and tracking down why the 4 extra bytes got written is evil.
  2. there are little to no reasons why you need to serialize what is effectively a variable sized type to disk; if you want it to be a usize, cast the known length thing after you deserialize; if you want to serialize a usize, choose a u32 or u64 and serialize, so all machines can write the same on-disk/wire datatype.

Unless someone provides compelling reasons to not remove, I will do so; please let me know if you really need this feature!

m4b commented 4 years ago

I duped my own bug I filed 2 months ago #56