其他分享
首页 > 其他分享> > Rustlings_if

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));
    }
}

标签:assert,if1,i32,Rustlings,fn,test,bigger
来源: https://www.cnblogs.com/nightwindnw/p/Rustlings_2.html