Simple guessing number with Rust

Implement a simple code game to understand more about Rust.

Photo by Julian Hochgesang on Unsplash

Here is the code for implement the game.

The game is allow user to guess from 0 to 3 for just one time. If they’re correct, show “You’re right”. If they’re wrong, show “You’re wrong” with the correct answer number is.

In Rust we have variable that is immutable or mutable.

To use the rand library, we need to add dependency to “Cargo.toml”.

rand = "*"

When running the code we will see




That’s it.

Thanks for reading my post.

~~PEACE ~~

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store