Skip to content

Commit f3ac029

Browse files
author
yumetski
committed
update
1 parent 341827f commit f3ac029

File tree

16 files changed

+36
-35
lines changed

16 files changed

+36
-35
lines changed

exercises/functions/functions1.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
44
// hint.
55

6-
// I AM NOT DONE
76

87
fn main() {
98
call_me();
109
}
10+
11+
fn call_me() {
12+
13+
}

exercises/functions/functions2.rs

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

6-
// I AM NOT DONE
76

87
fn main() {
98
call_me(3);
109
}
1110

12-
fn call_me(num:) {
11+
fn call_me(num:i32) {
1312
for i in 0..num {
1413
println!("Ring! Call number {}", i + 1);
1514
}

exercises/functions/functions3.rs

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

6-
// I AM NOT DONE
76

87
fn main() {
9-
call_me();
8+
call_me(10);
109
}
1110

1211
fn call_me(num: u32) {

exercises/functions/functions4.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
99
// hint.
1010

11-
// I AM NOT DONE
1211

1312
fn main() {
1413
let original_price = 51;
1514
println!("Your sale price is {}", sale_price(original_price));
1615
}
1716

18-
fn sale_price(price: i32) -> {
17+
fn sale_price(price: i32) -> i32{
1918
if is_even(price) {
2019
price - 10
2120
} else {

exercises/functions/functions5.rs

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

6-
// I AM NOT DONE
76

87
fn main() {
98
let answer = square(3);
109
println!("The square of 3 is {}", answer);
1110
}
1211

1312
fn square(num: i32) -> i32 {
14-
num * num;
13+
num * num
1514
}

exercises/if/if1.rs

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

5-
// I AM NOT DONE
65

76
pub fn bigger(a: i32, b: i32) -> i32 {
8-
// Complete this function to return the bigger number!
9-
// Do not use:
10-
// - another function call
11-
// - additional variables
7+
if a > b {
8+
a
9+
}else {
10+
b
11+
}
1212
}
1313

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

exercises/if/if2.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
//
66
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
77

8-
// I AM NOT DONE
98

109
pub fn foo_if_fizz(fizzish: &str) -> &str {
1110
if fizzish == "fizz" {
1211
"foo"
13-
} else {
14-
1
12+
} else if fizzish == "fuzz" {
13+
"bar"
14+
}else {
15+
"baz"
1516
}
1617
}
1718

exercises/if/if3.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
//
33
// Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint.
44

5-
// I AM NOT DONE
65

76
pub fn animal_habitat(animal: &str) -> &'static str {
87
let identifier = if animal == "crab" {
98
1
109
} else if animal == "gopher" {
11-
2.0
10+
2
1211
} else if animal == "snake" {
1312
3
1413
} else {
15-
"Unknown"
14+
4
1615
};
1716

1817
// DO NOT CHANGE THIS STATEMENT BELOW

exercises/intro/intro2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
66
// hint.
77

8-
// I AM NOT DONE
98

109
fn main() {
11-
println!("Hello {}!");
10+
println!("Hello {}!", "world");
1211
}

exercises/quiz1.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313
//
1414
// No hints this time ;)
1515

16-
// I AM NOT DONE
1716

1817
// Put your function here!
1918
// fn calculate_price_of_apples {
2019

2120
// Don't modify this function!
21+
22+
fn calculate_price_of_apples(num: i32) -> i32 {
23+
if num <= 40 {
24+
num * 2
25+
}else {
26+
num
27+
}
28+
}
29+
30+
2231
#[test]
2332
fn verify_test() {
2433
let price1 = calculate_price_of_apples(35);

0 commit comments

Comments
 (0)