Skip to content

Commit c036ada

Browse files
author
0xHaris
committed
added color
1 parent 2eafd3a commit c036ada

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ edition = "2021"
99
[dependencies]
1010

1111
rand = "0.3.14"
12+
colored = "2.0.0"

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rand::Rng;
22
use std::cmp::Ordering;
33
use std::io;
4+
use colored::*;
45
fn main() {
56
println!("Guess the number!");
67

@@ -23,10 +24,10 @@ fn main() {
2324
println!("You guessed: {}", guess);
2425

2526
match guess.cmp(&secret_number) {
26-
Ordering::Less => println!("Too small!"),
27-
Ordering::Greater => println!("Too big"),
27+
Ordering::Less => println!("{}", "Too small!".red()),
28+
Ordering::Greater => println!("{}", "Too big".red()),
2829
Ordering::Equal => {
29-
println!("You win!");
30+
println!("{}", "You win!".green());
3031
break;
3132
}
3233
}

0 commit comments

Comments
 (0)