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

Add Comparison operator to UUID #11352

Merged
merged 6 commits into from
Oct 29, 2021

Conversation

darkstego
Copy link
Contributor

According to RFC 4122, UUIDs are comparable. This implements the spaceship operator on UUIDs according to the specification.

Implements #11023

UUIDs are comparable according to RFC 4122. This implements the
comparison according to the spec.
spec/std/uuid_spec.cr Outdated Show resolved Hide resolved
src/uuid.cr Outdated Show resolved Hide resolved
@darkstego
Copy link
Contributor Author

I would point out that if StaticArray is gonna end up being comparable, this can be cleaned up even more by comparing the arrays.

@straight-shoota straight-shoota added this to the 1.3.0 milestone Oct 25, 2021
@jkthorne
Copy link
Contributor

I dont see the comparable part in the RFC. What section is it in?
I dont see why UUIDs cannot be compared but, I am curious why you would compare them.

@straight-shoota
Copy link
Member

A use case is described in #11023 (comment)

@henrikac
Copy link
Contributor

@bytes <=> other.bytes should be possible if #11364 gets approved and merged.

@darkstego
Copy link
Contributor Author

I dont see the comparable part in the RFC. What section is it in?

Implementations section page 24 has a code example of UUID compare

@straight-shoota straight-shoota merged commit 20b958b into crystal-lang:master Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants