AG UUID

Rust UUID

How to generate a standard UUID (typically v4) in Rust, using the standard library or a widely used package.

Code

main.rs
use uuid::Uuid;

let id = Uuid::new_v4();
println!("{}", id);
// Cargo.toml: uuid = { version = "1", features = ["v4"] }
Most languages provide v4 (random) out of the box, while v7 or ULID may require a separate library.

View version reference →