https://github.com/dmgk/zig-uuid
Fast, allocation-free v4 UUIDs in Zig
https://github.com/dmgk/zig-uuid
uuid uuid-generator uuidv4 zig zig-package ziglang
Last synced: about 1 year ago
JSON representation
Fast, allocation-free v4 UUIDs in Zig
- Host: GitHub
- URL: https://github.com/dmgk/zig-uuid
- Owner: dmgk
- License: 0bsd
- Created: 2021-05-22T22:24:06.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-27T18:55:08.000Z (about 2 years ago)
- Last Synced: 2025-04-14T11:55:38.887Z (about 1 year ago)
- Topics: uuid, uuid-generator, uuidv4, zig, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 7.81 KB
- Stars: 16
- Watchers: 1
- Forks: 11
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast, allocation-free v4 UUIDs in Zig
## Example
```zig
const std = @import("std");
const UUID = @import("uuid.zig").UUID;
pub fn main() !void {
// generate
const uuid1 = UUID.init();
std.debug.print("{}\n", .{uuid1});
// parse
const uuid2 = try UUID.parse("3df6f0e4-f9b1-4e34-ad70-33206069b995");
std.debug.print("{}\n", .{uuid2});
}
```
```
$ zig run example.zig
78c33481-4c67-4202-ba8d-11ee1dfaad24
3df6f0e4-f9b1-4e34-ad70-33206069b995
```
### Tests
```bash
zig test uuid.zig
```
```bash
Test [3/3] test.check to_string works...
First call to_string 851d0256-c62c-43b0-bf15-71da00bafb30
Second call to_string 851d0256-c62c-43b0-bf15-71da00bafb30
All 3 tests passed.
```