-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an example of generating bulk v7 UUIDs
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
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
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
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,15 @@ | ||
//! Generating a sortable UUID. | ||
//! | ||
//! If you enable the `v7` feature you can generate sortable UUIDs. | ||
//! This example avoids the synchronization cost of `Uuid::now_v7()` | ||
//! when generating UUIDs in bulk. | ||
fn main() { | ||
use uuid::{ContextV7, Timestamp, Uuid}; | ||
|
||
let ctxt = ContextV7::new(); | ||
|
||
for _ in 0..10 { | ||
println!("{}", Uuid::new_v7(Timestamp::now(&ctxt))); | ||
} | ||
} |