Skip to content

Enhance Guid::from_values and Guid::fmt #279

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

Closed
timrobertsdev opened this issue Sep 6, 2021 · 0 comments
Closed

Enhance Guid::from_values and Guid::fmt #279

timrobertsdev opened this issue Sep 6, 2021 · 0 comments

Comments

@timrobertsdev
Copy link
Contributor

Hi, since const panics are now a thing, we can assert that the node id passed to Guid::from_values has the high 16 bits cleared and take a u64 instead of a [u8; 6]. I've also cleaned up the Display implementation for Guid, replacing the manual bitshifts with the u16::from_be_bytes and u64::from_be_bytes stdlib functions. The functionality is identical (it actually ends up compiling down to the same thing, according to godbolt), but the code ends up being simpler and easier to read.

The included test suite passes with either or both changes.

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

No branches or pull requests

1 participant