Rustlings_if

练习过程中的随手记,很多问题也未深究,,简单问题可能直接贴改完之后的代码,..分享出来,若能帮助大家,意外乐趣

if1.rs

// if1.rs


pub fn bigger(a: i32, b: i32) -> i32 {
    // Complete this function to return the bigger number!
    // Do not use:
    // - another function call
    // - additional variables
    // Execute `rustlings hint if1` for hints
    if a >b {
        a
    }else { b }
}

// Don't mind this for now :)
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn ten_is_bigger_than_eight() {
        assert_eq!(10, bigger(10, 8));
    }

    #[test]
    fn fortytwo_is_bigger_than_thirtytwo() {
        assert_eq!(42, bigger(32, 42));
    }
}
posted @ 2020-06-11 12:40  GoudaX  阅读(96)  评论(0编辑  收藏  举报