File tree Expand file tree Collapse file tree 16 files changed +36
-35
lines changed
Expand file tree Collapse file tree 16 files changed +36
-35
lines changed Original file line number Diff line number Diff line change 33// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
44// hint.
55
6- // I AM NOT DONE
76
87fn main ( ) {
98 call_me ( ) ;
109}
10+
11+ fn call_me ( ) {
12+
13+ }
Original file line number Diff line number Diff line change 33// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
44// hint.
55
6- // I AM NOT DONE
76
87fn 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 }
Original file line number Diff line number Diff line change 33// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
44// hint.
55
6- // I AM NOT DONE
76
87fn main ( ) {
9- call_me ( ) ;
8+ call_me ( 10 ) ;
109}
1110
1211fn call_me ( num : u32 ) {
Original file line number Diff line number Diff line change 88// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
99// hint.
1010
11- // I AM NOT DONE
1211
1312fn 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 {
Original file line number Diff line number Diff line change 33// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
44// hint.
55
6- // I AM NOT DONE
76
87fn main ( ) {
98 let answer = square ( 3 ) ;
109 println ! ( "The square of 3 is {}" , answer) ;
1110}
1211
1312fn square ( num : i32 ) -> i32 {
14- num * num;
13+ num * num
1514}
Original file line number Diff line number Diff line change 22//
33// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
44
5- // I AM NOT DONE
65
76pub 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 :)
Original file line number Diff line number Diff line change 55//
66// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
77
8- // I AM NOT DONE
98
109pub 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
Original file line number Diff line number Diff line change 22//
33// Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint.
44
5- // I AM NOT DONE
65
76pub 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
Original file line number Diff line number Diff line change 55// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
66// hint.
77
8- // I AM NOT DONE
98
109fn main ( ) {
11- println ! ( "Hello {}!" ) ;
10+ println ! ( "Hello {}!" , "world" ) ;
1211}
Original file line number Diff line number Diff line change 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]
2332fn verify_test ( ) {
2433 let price1 = calculate_price_of_apples ( 35 ) ;
You can’t perform that action at this time.
0 commit comments