Make ctors that accept slices infallible using arrays and other breaking changes #536

Merged
KodrAus merged 8 commits from feat/infallible-ctors into main 2021-10-30 16:45:44 -05:00
KodrAus commented 2021-10-28 21:11:01 -05:00 (Migrated from github.com)

Closes #150 #459 #329 #533

Infallible array inputs

This is a breaking change that changes &[u8] inputs to Uuid methods to &[u8; N]. This lets us make these methods infallible so they can be used in other const functions. If a caller only has a &[u8] to pass in, they can use try_into to convert it into a &[u8; N].

Infallible variant

It's not possible for the variant to ever return None, so we don't need to return an Option for it.

Compact serializer by default

We now serialize a 16 element tuple instead of a slice of bytes in non-human-readable formats.

Closes #150 #459 #329 #533 # Infallible array inputs This is a breaking change that changes `&[u8]` inputs to `Uuid` methods to `&[u8; N]`. This lets us make these methods infallible so they can be used in other `const` functions. If a caller only has a `&[u8]` to pass in, they can use `try_into` to convert it into a `&[u8; N]`. # Infallible variant It's not possible for the variant to ever return `None`, so we don't need to return an `Option` for it. # Compact serializer by default We now serialize a 16 element tuple instead of a slice of bytes in non-human-readable formats.
Dylan-DPC-zz (Migrated from github.com) reviewed 2021-10-28 21:11:01 -05:00
kinggoesgaming (Migrated from github.com) reviewed 2021-10-28 21:11:01 -05:00
KodrAus commented 2021-10-29 01:43:20 -05:00 (Migrated from github.com)

While working on this I've also catalogued our unstable dependencies. I think the only public one left is winapi, which is unlikely to change in a hurry, but we should consider shifting it out into an external library that just offers two functions:

pub fn uuid_from_guid(guid: Guid) -> Uuid;

pub fn guid_from_uuid(uuid: Uuid) -> Guid;
While working on this I've also catalogued our unstable dependencies. I think the only public one left is `winapi`, which is unlikely to change in a hurry, but we should consider shifting it out into an external library that just offers two functions: ```rust pub fn uuid_from_guid(guid: Guid) -> Uuid; pub fn guid_from_uuid(uuid: Uuid) -> Guid; ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid!536
No description provided.