rustlings

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

if1.rs (691B)


      1 fn bigger(a: i32, b: i32) -> i32 {
      2     // TODO: Complete this function to return the bigger number!
      3     // If both numbers are equal, any of them can be returned.
      4     // Do not use:
      5     // - another function call
      6     // - additional variables
      7     if a > b { a } else { b }
      8 }
      9 
     10 fn main() {
     11     // You can optionally experiment here.
     12 }
     13 
     14 // Don't mind this for now :)
     15 #[cfg(test)]
     16 mod tests {
     17     use super::*;
     18 
     19     #[test]
     20     fn ten_is_bigger_than_eight() {
     21         assert_eq!(10, bigger(10, 8));
     22     }
     23 
     24     #[test]
     25     fn fortytwo_is_bigger_than_thirtytwo() {
     26         assert_eq!(42, bigger(32, 42));
     27     }
     28 
     29     #[test]
     30     fn equal_numbers() {
     31         assert_eq!(42, bigger(42, 42));
     32     }
     33 }