diff options
Diffstat (limited to 'rustlings/exercises')
| -rw-r--r-- | rustlings/exercises/02_functions/functions1.rs | 4 | ||||
| -rw-r--r-- | rustlings/exercises/02_functions/functions2.rs | 3 | ||||
| -rw-r--r-- | rustlings/exercises/02_functions/functions3.rs | 3 | ||||
| -rw-r--r-- | rustlings/exercises/02_functions/functions4.rs | 7 | ||||
| -rw-r--r-- | rustlings/exercises/02_functions/functions5.rs | 3 |
5 files changed, 7 insertions, 13 deletions
diff --git a/rustlings/exercises/02_functions/functions1.rs b/rustlings/exercises/02_functions/functions1.rs index a812c21..5dbae07 100644 --- a/rustlings/exercises/02_functions/functions1.rs +++ b/rustlings/exercises/02_functions/functions1.rs @@ -1,4 +1,6 @@ -// TODO: Add some function with the name `call_me` without arguments or a return value. +fn call_me() { + println!("call_me()"); +} fn main() { call_me(); // Don't change this line diff --git a/rustlings/exercises/02_functions/functions2.rs b/rustlings/exercises/02_functions/functions2.rs index 2c773c6..27f2cc7 100644 --- a/rustlings/exercises/02_functions/functions2.rs +++ b/rustlings/exercises/02_functions/functions2.rs @@ -1,5 +1,4 @@ -// TODO: Add the missing type of the argument `num` after the colon `:`. -fn call_me(num:) { +fn call_me(num: u32) { for i in 0..num { println!("Ring! Call number {}", i + 1); } diff --git a/rustlings/exercises/02_functions/functions3.rs b/rustlings/exercises/02_functions/functions3.rs index 8d65477..88dff5b 100644 --- a/rustlings/exercises/02_functions/functions3.rs +++ b/rustlings/exercises/02_functions/functions3.rs @@ -5,6 +5,5 @@ fn call_me(num: u8) { } fn main() { - // TODO: Fix the function call. - call_me(); + call_me(3); } diff --git a/rustlings/exercises/02_functions/functions4.rs b/rustlings/exercises/02_functions/functions4.rs index b22bffd..2c5a3b0 100644 --- a/rustlings/exercises/02_functions/functions4.rs +++ b/rustlings/exercises/02_functions/functions4.rs @@ -1,14 +1,9 @@ -// This store is having a sale where if the price is an even number, you get 10 -// Rustbucks off, but if it's an odd number, it's 3 Rustbucks off. -// Don't worry about the function bodies themselves, we are only interested in -// the signatures for now. - fn is_even(num: i64) -> bool { num % 2 == 0 } // TODO: Fix the function signature. -fn sale_price(price: i64) -> { +fn sale_price(price: i64) -> i64 { if is_even(price) { price - 10 } else { diff --git a/rustlings/exercises/02_functions/functions5.rs b/rustlings/exercises/02_functions/functions5.rs index 34a2ac7..024010f 100644 --- a/rustlings/exercises/02_functions/functions5.rs +++ b/rustlings/exercises/02_functions/functions5.rs @@ -1,6 +1,5 @@ -// TODO: Fix the function body without changing the signature. fn square(num: i32) -> i32 { - num * num; + num * num } fn main() { |