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
If a custom field takes up, say, 48 bits, and each bit can be arbitrarily anything, then it should be able to infallibly be converted from a [u8; 6].
But the current generated code performs a fallible try_from(u64), which would require wrangling a series of bytes into a [u8; 8], and then converted to a u64.
The text was updated successfully, but these errors were encountered:
Can you provide more context for this request ?
Currently the rust generator only produces TryFrom implementations for the nearest scalar type; not TryFrom<[u8;N]>.
For example, lets consider this field declaration:
custom_field Field : 48
Right now, I can initialize it like this:
Field::try_from(0_u64).unwrap();
However, something that is 48 bits long is exactly 6 bytes long.
That means that if I know which 6 bytes I want to initialize Field with, I first have to wrangle it into a u64, and then initialize Field in a way that may fail if I wrangle my bytes into a u64 incorrectly`.
If Field were to implement From<[u8; 6]>, then there are fewer things that could go wrong in my conversion. (ignoring endianness, which complicates matters)
If a custom field takes up, say, 48 bits, and each bit can be arbitrarily anything, then it should be able to infallibly be converted from a [u8; 6].
But the current generated code performs a fallible try_from(u64), which would require wrangling a series of bytes into a [u8; 8], and then converted to a u64.
The text was updated successfully, but these errors were encountered: