functions done

This commit is contained in:
Artur 2023-12-20 21:49:05 -06:00
parent 9be3488d41
commit a54818ef45
5 changed files with 9 additions and 12 deletions

View File

@ -3,8 +3,9 @@
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
call_me();
fn call_me() {
};
}

View File

@ -3,13 +3,12 @@
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
call_me(3);
}
fn call_me(num:) {
fn call_me(num:i32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}

View File

@ -3,10 +3,9 @@
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
call_me();
call_me(10000);
}
fn call_me(num: u32) {

View File

@ -8,14 +8,13 @@
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
let original_price = 51;
let original_price: u32 = 51;
println!("Your sale price is {}", sale_price(original_price));
}
fn sale_price(price: i32) -> {
fn sale_price(price: u32) -> u32 {
if is_even(price) {
price - 10
} else {
@ -23,6 +22,6 @@ fn sale_price(price: i32) -> {
}
}
fn is_even(num: i32) -> bool {
fn is_even(num: u32) -> bool {
num % 2 == 0
}

View File

@ -3,7 +3,6 @@
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
// hint.
// I AM NOT DONE
fn main() {
let answer = square(3);
@ -11,5 +10,5 @@ fn main() {
}
fn square(num: i32) -> i32 {
num * num;
return num * num;
}