You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in the case of u8 and i8, only TryRead<Endian> and TryWrite<Endian> are implemented. In reality, endianness doesn't matter for single byte values, and you end up writing verbose code that seems to hint that there's some sort of different handling of the bytes.
// these two are the same net resultlet u1:u8 = bytes.read_with(ofs, byte::ctx::Endian::Little)?;let u2:u8 = bytes.read_with(ofs, byte::ctx::Endian::Big)?;// dittolet i1:i8 = bytes.read_with(ofs, byte::ctx::Endian::Little)?;let i2:i8 = bytes.read_with(ofs, byte::ctx::Endian::Big)?;// yet i cant use the default context (`()`) even though it makes my code a lot more readable // and doesn't leave me wondering why I need to specify an endianness for a single-byte value.let sensible:u8 = bytes.read(ofs);let sensible2:i8 = bytes.read(ofs);
Perhaps the TryRead for u8 and i8 should really be impl<'a, Ctx> TryRead<'a, Ctx> ? Or at the very least, also have a TryRead<()>/TryWrite<()> like bool (and conversely, maybe bool should be generic on context)?
The text was updated successfully, but these errors were encountered:
Hey, thanks for the suggestion. I really appreciate your input. My advice would be to implement i8 and u8 with the () context. If you're interested, I'd love it if you could submit a pull request with your proposed changes.
Currently, in the case of
u8
andi8
, onlyTryRead<Endian>
andTryWrite<Endian>
are implemented. In reality, endianness doesn't matter for single byte values, and you end up writing verbose code that seems to hint that there's some sort of different handling of the bytes.Perhaps the TryRead for u8 and i8 should really be
impl<'a, Ctx> TryRead<'a, Ctx>
? Or at the very least, also have aTryRead<()>/TryWrite<()>
likebool
(and conversely, maybebool
should be generic on context)?The text was updated successfully, but these errors were encountered: