Skip to content

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

Closed
@timrobertsdev

Description

@timrobertsdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions