Add the uuid crate to your Cargo.toml with the v4 feature, then import and call Uuid::new_v4() to generate a random UUID.
use uuid::Uuid;
fn main() {
let my_uuid = Uuid::new_v4();
println!("Generated UUID: {my_uuid}");
}
Add this to your Cargo.toml:
[dependencies]
uuid = { version = "1.0", features = ["v4"] }