-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quality-of-life improvements for tagged UUIDs (#63)
- Loading branch information
1 parent
6724f70
commit af06825
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong. |
||
public init?(uuidString string: String) { | ||
guard let uuid = UUID(uuidString: string) | ||
else { return nil } | ||
self.init(uuid) | ||
} | ||
} |
Is the middle
BEED
with aD
on purpose? I'd have expected anF
for 'BEEF'.