From 2a12b632077a5686be2fc0f6f3b3201b184f2347 Mon Sep 17 00:00:00 2001 From: Leonardo Freua Date: Tue, 14 Sep 2021 10:18:47 -0300 Subject: [PATCH] Solve function exercises. --- exercises/functions/functions1.rs | 3 ++- exercises/functions/functions2.rs | 3 +-- exercises/functions/functions3.rs | 3 +-- exercises/functions/functions4.rs | 4 +--- exercises/functions/functions5.rs | 3 +-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/exercises/functions/functions1.rs b/exercises/functions/functions1.rs index 31125278..48252d9e 100644 --- a/exercises/functions/functions1.rs +++ b/exercises/functions/functions1.rs @@ -1,8 +1,9 @@ // functions1.rs // Make me compile! Execute `rustlings hint functions1` for hints :) -// I AM NOT DONE fn main() { call_me(); } + +fn call_me() {} \ No newline at end of file diff --git a/exercises/functions/functions2.rs b/exercises/functions/functions2.rs index 5721a172..356268ba 100644 --- a/exercises/functions/functions2.rs +++ b/exercises/functions/functions2.rs @@ -1,13 +1,12 @@ // functions2.rs // Make me compile! Execute `rustlings hint functions2` for hints :) -// I AM NOT DONE fn main() { call_me(3); } -fn call_me(num:) { +fn call_me(num: u32) { for i in 0..num { println!("Ring! Call number {}", i + 1); } diff --git a/exercises/functions/functions3.rs b/exercises/functions/functions3.rs index ed5f839f..fbdc7215 100644 --- a/exercises/functions/functions3.rs +++ b/exercises/functions/functions3.rs @@ -1,10 +1,9 @@ // functions3.rs // Make me compile! Execute `rustlings hint functions3` for hints :) -// I AM NOT DONE fn main() { - call_me(); + call_me(3); } fn call_me(num: u32) { diff --git a/exercises/functions/functions4.rs b/exercises/functions/functions4.rs index 58637e4c..b6af7c4b 100644 --- a/exercises/functions/functions4.rs +++ b/exercises/functions/functions4.rs @@ -4,14 +4,12 @@ // 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. -// I AM NOT DONE - fn main() { let original_price = 51; println!("Your sale price is {}", sale_price(original_price)); } -fn sale_price(price: i32) -> { +fn sale_price(price: i32) -> i32 { if is_even(price) { price - 10 } else { diff --git a/exercises/functions/functions5.rs b/exercises/functions/functions5.rs index d22aa6c8..ee79e792 100644 --- a/exercises/functions/functions5.rs +++ b/exercises/functions/functions5.rs @@ -1,7 +1,6 @@ // functions5.rs // Make me compile! Execute `rustlings hint functions5` for hints :) -// I AM NOT DONE fn main() { let answer = square(3); @@ -9,5 +8,5 @@ fn main() { } fn square(num: i32) -> i32 { - num * num; + num * num }