summaryrefslogtreecommitdiff
path: root/solutions/02_functions/functions4.rs
blob: f823de24ef0b74a2fb777dcf7683f20831ca6b31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn is_even(num: i64) -> bool {
    num % 2 == 0
}

// The return type must always be annotated.
fn sale_price(price: i64) -> i64 {
    if is_even(price) {
        price - 10
    } else {
        price - 3
    }
}

fn main() {
    let original_price = 51;
    println!("Your sale price is {}", sale_price(original_price));
}