Complete functions 2,3,4

This commit is contained in:
Stirling Hostetter 2022-11-02 11:41:22 -05:00
parent 9978dd678f
commit 2a7fcefae0
3 changed files with 4 additions and 10 deletions

View File

@ -1,13 +1,11 @@
// functions2.rs
// 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

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

View File

@ -7,14 +7,12 @@
// in the signatures for now. If anything, this is a good way to peek ahead
// to future exercises!)
// 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: u32) -> u32 {
if is_even(price) {
price - 10
} else {
@ -22,6 +20,6 @@ fn sale_price(price: i32) -> {
}
}
fn is_even(num: i32) -> bool {
fn is_even(num: u32) -> bool {
num % 2 == 0
}