Ask coding questions

← Back to all posts
Extern Crate rand error
AmirahH (0)

https://repl.it/@AmirahH/CrispDramaticWearables

My program presents both players with 5 questions each. The question shows four possible answers and tally points for each player. The program also includes a Question type with accessors, mutators and an array that holds the 10 question objects.

The error message is from the random method from the extern crate rand.

unresolved name rand::random [E0425]

Commentshotnewtop
PYer (3571)

I do not know rust, but I can tell you that in python, the module is named random and the function randint. Maybe you switch random with rand? The error shows

exit status 101
error[E0425]: cannot find function `random` in module `rand`
   --> main.rs:200:19
    |
200 |         game.roll(rand::random::<i32>() % 5 + 1);
    |                   ^^^^^^^^^^^^^^^^^^^ not found in `rand`

Sorry if I am incorrect, I have never coded in this language.

John_WardWard (318)

@AmirahH My advice is to go join the discord server, and then ask someone on there, as I have zero knowledge of Rust and you are likely to find much more experienced coders on the server.