Skip to content

Commit

Permalink
Quality-of-life improvements for tagged UUIDs (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored Dec 13, 2022
1 parent 6724f70 commit af06825
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Sources/Tagged/UUID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

extension Tagged where RawValue == UUID {
/// Generates a tagged UUID.
///
/// Equivalent to `Tagged<Tag, _>(UUID(())`.
public init() {
self.init(UUID())
}

/// Creates a tagged UUID from a string representation.
///
/// - Parameter string: The string representation of a UUID, such as
/// `DEADBEEF-DEAD-BEED-DEAD-BEEFDEADBEEF`.

This comment has been minimized.

Copy link
@SpacyRicochet

SpacyRicochet Feb 6, 2023

Is the middle BEED with a D on purpose? I'd have expected an F for 'BEEF'.

public init?(uuidString string: String) {
guard let uuid = UUID(uuidString: string)
else { return nil }
self.init(uuid)
}
}

0 comments on commit af06825

Please sign in to comment.