Add Nil Version #176

Closed
kinggoesgaming wants to merge 53 commits from nil-variant into breaking
kinggoesgaming commented 2018-03-18 21:10:26 -05:00 (Migrated from github.com)

I'm submitting a ...

  • bug fix
  • feature enhancement
  • deprecation or removal
  • refactor

Description

Adds Nil variant to the UuidVersion.

Motivation

nil Uuid, containing all zeros, is a valid Uuid, as per the specification. This will allow users doing pattern matching to explicitly check for it.

Tests

Updated test_nil to ensure that

Related Issue(s)

closes #133

<!-- As we are working towards a stable version of uuid, we require that you open an issue, before submitting a pull request. If the pull request is imcomplete, prepend the Title with WIP: --> **I'm submitting a ...** - [ ] bug fix - [x] feature enhancement - [ ] deprecation or removal - [ ] refactor # Description Adds `Nil` variant to the `UuidVersion`. # Motivation `nil` `Uuid`, containing all zeros, is a valid `Uuid`, as per the specification. This will allow users doing pattern matching to explicitly check for it. # Tests Updated `test_nil` to ensure that # Related Issue(s) closes #133
radix (Migrated from github.com) reviewed 2018-03-18 21:10:26 -05:00
Dylan-DPC-zz (Migrated from github.com) reviewed 2018-03-19 12:41:23 -05:00
KodrAus (Migrated from github.com) reviewed 2018-03-19 17:50:06 -05:00
KodrAus (Migrated from github.com) left a comment

Thanks @kinggoesgaming! I think we should also add support for UuidVersion::Nil to the Uuid::new method.

Thanks @kinggoesgaming! I think we should also add support for `UuidVersion::Nil` to the `Uuid::new` method.
@ -645,0 +698,4 @@
/// use uuid::Uuid;
/// use uuid::UuidBytes;
///
///
KodrAus (Migrated from github.com) commented 2018-03-19 17:48:14 -05:00

If we're going to add an explicit Nil variant then I think we should change this match to 0 if self.is_nil(), since this version is a bit unique in purely describing the value of the uuid. We can prove when the version is not valid. Otherwise:

let uuid = Uuid::from_uuid_bytes([4, 54, 67, 12, 43, 2, 2, 76, 32, 50, 87, 5, 1, 33, 43, 87]);

assert_eq!(nil.get_version(), Some(UuidVersion::Nil));

Is actually true, even though that uuid is definitely not nil.

If we're going to add an explicit `Nil` variant then I think we should change this match to `0 if self.is_nil()`, since this version is a bit unique in purely describing the value of the uuid. We can prove when the version is not valid. Otherwise: ```rust let uuid = Uuid::from_uuid_bytes([4, 54, 67, 12, 43, 2, 2, 76, 32, 50, 87, 5, 1, 33, 43, 87]); assert_eq!(nil.get_version(), Some(UuidVersion::Nil)); ``` Is actually true, even though that uuid is definitely not nil.
kinggoesgaming commented 2018-03-19 19:02:10 -05:00 (Migrated from github.com)

@KodrAus I was actually thinking of removing the Uuid::new function. It serves no purpose other than for v4 users.

@KodrAus I was actually thinking of removing the `Uuid::new` function. It serves no purpose other than for `v4` users.
kinggoesgaming (Migrated from github.com) reviewed 2018-03-19 23:28:02 -05:00
@ -645,0 +698,4 @@
/// use uuid::Uuid;
/// use uuid::UuidBytes;
///
///
kinggoesgaming (Migrated from github.com) commented 2018-03-19 23:28:02 -05:00

Fixed

Fixed
KodrAus (Migrated from github.com) reviewed 2018-03-19 23:50:01 -05:00
KodrAus (Migrated from github.com) left a comment
No description provided.
Yeh, removing `new` at some point sounds good to me. I'd be interested to know how many people are actually using it. It might be good to add a test case to ensure that `Uuid::from_uuid_bytes([4, 54, 67, 12, 43, 2, 2, 76, 32, 50, 87, 5, 1, 33, 43, 87])` has a version of `None`, but otherwise looks good to me!
Dylan-DPC-zz (Migrated from github.com) reviewed 2018-03-20 16:53:11 -05:00
kinggoesgaming commented 2018-03-20 21:09:37 -05:00 (Migrated from github.com)

RIP... wrong merge :(

Opening a new PR

RIP... wrong merge :( Opening a new PR

Pull request closed

Sign in to join this conversation.
No reviewers
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!176
No description provided.