Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

make-uuid.rs 606 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. extern crate structopt;
  2. extern crate uuid;
  3. use structopt::StructOpt;
  4. use uuid::Uuid;
  5. #[derive(StructOpt, Debug)]
  6. #[structopt(name="make-uuid")]
  7. struct Opt {
  8. #[structopt(short="n", long="namespace")]
  9. namespace: Option<String>,
  10. #[structopt(name = "STRING")]
  11. string: Vec<String>
  12. }
  13. fn main() {
  14. let opt = Opt::from_args();
  15. let ns = match opt.namespace {
  16. None => Uuid::nil(),
  17. Some(ref s) if s == "url" => uuid::NAMESPACE_URL,
  18. Some(ref s) => uuid::Uuid::new_v5(&uuid::Uuid::nil(), s)
  19. };
  20. for s in opt.string {
  21. let u = Uuid::new_v5(&ns, &s);
  22. println!("{}\t{}", u, s);
  23. }
  24. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...