Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement write_uXX_from #166

Closed
wants to merge 1 commit into from

Conversation

luizirber
Copy link

This was discussed in #155, and makes my life much easier when serializing big vectors.

For now I only implemented write_u32_from, but if this looks OK I can go implement all the others too. I also created slice_to_u8 based on slice_to_u8_mut, but I don't think the comment about "modification of the binary representation of any Copy type" applies to it.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API looks fine, and slice_to_u8 is okay, but the implementation doesn't actually take byte order into account.

///
/// let mut wtr = Vec::new();
/// wtr.write_u32_from::<BigEndian>(&src).unwrap();
/// assert_eq!(&wtr, &[255, 0, 0, 0, 4, 255, 0, 0]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These bytes are little endian. Not big endian.

Which makes sense, because the implementation never takes byte order into account. T is unused.

@luizirber luizirber closed this Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants