rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

functions4.rs (324B)


      1 fn is_even(num: i64) -> bool {
      2     num % 2 == 0
      3 }
      4 
      5 // The return type must always be annotated.
      6 fn sale_price(price: i64) -> i64 {
      7     if is_even(price) {
      8         price - 10
      9     } else {
     10         price - 3
     11     }
     12 }
     13 
     14 fn main() {
     15     let original_price = 51;
     16     println!("Your sale price is {}", sale_price(original_price));
     17 }