Skip to content

Commit 52ed5db

Browse files
First quiz and its related modules
1 parent 36e66b5 commit 52ed5db

File tree

22 files changed

+60
-98
lines changed

22 files changed

+60
-98
lines changed

exercises/error_handling/errors5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// This exercise uses some concepts that we won't get to until later in the course, like `Box` and the
66
// `From` trait. It's not important to understand them in detail right now, but you can read ahead if you like.
7-
// For now, think of the `Box<dyn ???>` type as an "I want anything that does ???" type, which, given
7+
// For now, think of the `Box<dyn ...>` type as an "I want anything that does ???" type, which, given
88
// Rust's usual standards for runtime safety, should strike you as somewhat lenient!
99

1010
// In short, this particular use case for boxes is for when you want to own a value and you care only that it is a

exercises/functions/functions1.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// functions1.rs
22
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a hint.
33

4-
// I AM NOT DONE
5-
64
fn main() {
75
call_me();
86
}
7+
8+
fn call_me() {
9+
println!("I'm Nidhal Messaoudi, a software developer going Rusty!!!");
10+
}

exercises/functions/functions2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// functions2.rs
22
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a hint.
33

4-
// I AM NOT DONE
5-
64
fn main() {
75
call_me(3);
86
}
97

10-
fn call_me(num:) {
8+
fn call_me(num: i32) {
119
for i in 0..num {
1210
println!("Ring! Call number {}", i + 1);
1311
}

exercises/functions/functions3.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// functions3.rs
22
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a hint.
33

4-
// I AM NOT DONE
5-
64
fn main() {
7-
call_me();
5+
call_me(12);
86
}
97

108
fn call_me(num: u32) {

exercises/functions/functions4.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
// in the signatures for now. If anything, this is a good way to peek ahead
88
// to future exercises!)
99

10-
// I AM NOT DONE
11-
1210
fn main() {
1311
let original_price = 51;
1412
println!("Your sale price is {}", sale_price(original_price));
1513
}
1614

17-
fn sale_price(price: i32) -> {
15+
fn sale_price(price: i32) -> i32 {
1816
if is_even(price) {
1917
price - 10
2018
} else {

exercises/functions/functions5.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// functions5.rs
22
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a hint.
33

4-
// I AM NOT DONE
5-
64
fn main() {
75
let answer = square(3);
86
println!("The square of 3 is {}", answer);
97
}
108

119
fn square(num: i32) -> i32 {
12-
num * num;
10+
return num * num;
1311
}

exercises/if/if1.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// if1.rs
22
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
33

4-
// I AM NOT DONE
5-
64
pub fn bigger(a: i32, b: i32) -> i32 {
75
// Complete this function to return the bigger number!
86
// Do not use:
97
// - another function call
108
// - additional variables
9+
if a > b {
10+
a
11+
} else {
12+
b
13+
}
1114
}
1215

1316
// Don't mind this for now :)

exercises/if/if2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
55
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
66

7-
// I AM NOT DONE
8-
97
pub fn foo_if_fizz(fizzish: &str) -> &str {
10-
if fizzish == "fizz" {
8+
if fizzish == "fuzz" {
9+
"bar"
10+
} else if fizzish == "fizz" {
1111
"foo"
1212
} else {
13-
1
13+
"baz"
1414
}
1515
}
1616

exercises/intro/intro1.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// when you change one of the lines below! Try adding a `println!` line, or try changing
1010
// what it outputs in your terminal. Try removing a semicolon and see what happens!
1111

12-
// I AM NOT DONE
13-
1412
fn main() {
1513
println!("Hello and");
1614
println!(r#" welcome to... "#);

exercises/intro/intro2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Make the code print a greeting to the world.
33
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a hint.
44

5-
// I AM NOT DONE
6-
75
fn main() {
8-
println!("Hello {}!");
6+
println!("Hello {}!", "World");
97
}

0 commit comments

Comments
 (0)