Skip to content

Conversation

jevonmao
Copy link
Contributor

As discussed in Swift Forums and implemented in several frameworks like Vapor, UUID meets the semantic contract of LosslessStringConvertible. This PR adds conformance of UUID to LosslessStringConvertible.

Closes #1292

Copy link
Contributor

@itingliu itingliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need an accompanying API proposal since this is changing the public interface. Do you have one?

/// Represents UUID strings, which can be used to uniquely identify types, interfaces, and other items.
@available(macOS 10.8, iOS 6.0, tvOS 9.0, watchOS 2.0, *)
public struct UUID : Hashable, Equatable, CustomStringConvertible, Sendable {
public struct UUID : Hashable, Equatable, CustomStringConvertible, Sendable, LosslessStringConvertible {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new conformance and the new init need to have the new availability annotation.

@jevonmao
Copy link
Contributor Author

@itingliu I added the proposal. Could you abbreviated review for this?

itingliu
itingliu previously approved these changes Jun 20, 2025
@itingliu
Copy link
Contributor

@swift-ci please test

XCTAssertTrue(uuid2 == uuid1)
}

func test_UUIDLosslessStringConvertible() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we just recently switched to use swift-testing two weeks ago. Do you mind rebasing main and updating this test to swift-testing?

@itingliu itingliu dismissed their stale review June 23, 2025 18:45

I left a comment asking if we could switch to swift-testing from XCTest. Dismissing this review so my comment doesn't get lost.

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

Successfully merging this pull request may close these issues.

Conform UUID to LosslessStringConvertible
2 participants