Member-only story

Rusty

Simple guessing number with Rust

Implement a simple code game to understand more about Rust.

Donald Le

--

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

Or

Wrong

That’s it.

Thanks for reading my post.

~~PEACE ~~

--

--

No responses yet