https://github.com/sameh-farouk/rust_guessing_game
a classic beginner programming problem in Rust
https://github.com/sameh-farouk/rust_guessing_game
Last synced: about 1 year ago
JSON representation
a classic beginner programming problem in Rust
- Host: GitHub
- URL: https://github.com/sameh-farouk/rust_guessing_game
- Owner: sameh-farouk
- Created: 2021-05-19T11:43:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-24T14:24:45.000Z (about 5 years ago)
- Last Synced: 2025-04-09T18:56:40.832Z (about 1 year ago)
- Language: Rust
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![LinkedIn][linkedin-shield]][linkedin-url]
Table of Contents
## About The Project
note: this project for-educational-purposes-only and it have very basic code in rust as i started to learn rust just yesterday.
this is a classic beginner programming problem: a guessing game. Here’s how it works: the program will generate a random integer between 1 and 100. It will then prompt the player to enter a guess. After a guess is entered, the program will indicate whether the guess is too low or too high. If the guess is correct, the game will print a congratulatory message and exit.
while i code this project I practiced the fundamentals and learnt about:
* `let`
* `match`
* methods
* associated functions
* using external crates
* using cargo
* handling Potential failure with the Result type
### Built With
* [Rust](https://www.rust-lang.org/)
## Getting Started
To get a local copy up and running follow these simple example steps.
### Prerequisites
* Rust
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
If you have installed Rustup some time ago, chances are your Rust version is out of date. Get the latest version of Rust by running `rustup update`.
### Installation
1. Clone the repo
```sh
git clone https://github.com/sameh-farouk/rust_guessing_game.git
```
3. cd into `rust_guessing_game`:
```sh
cd rust_guessing_game
```
4. Compile and run it in the same step using `cargo run` command:
```sh
cargo run
```
## Usage
```sh
$ cargo run
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
Finished dev [unoptimized + debuginfo] target(s) in 4.45s
Running `target/debug/guessing_game`
Guess the number!
Please input your guess.
10
You guessed: 10
Too small!
Please input your guess.
99
You guessed: 99
Too big!
Please input your guess.
foo
Please input your guess.
61
You guessed: 61
You win!
```
_For more examples, please refer to the [Guessing game tutorial](https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html)_
## Acknowledgements
* [The Rust Programming Language: The Book](https://doc.rust-lang.org/book/title-page.html)
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/sameh-farouk-software-developer/