Uuid build error with cargo web

Consider this example:

use uuid;
fn main() {println!("{}", uuid::Uuid::new_v4().to_string());}

with dependency:

uuid = { version = "0.8.1", features = ["v4"] }

It will build without problems using cargo build, but when I try to use cargo web build, I get:

error[E0599]: no function or associated item named 'new_v4' found for struct 'uuid::Uuid' in the current scope

Can anyone help me with this? I suspect the use of rand::RngCore might be a problem ...

It looks like the crate disables v4 in WASM, unless you enable feature = "stdweb" or feature = "wasm-bindgen":


1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.