vivian-essentials 0.1.0

vivian's essential utilities
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub fn tern<T>(cond: bool, if_true: T, if_false: T) -> T {
    if cond {
        if_true
    } else {
        if_false
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn test_tern() {
        assert_eq!(5, super::tern(true, 5, 0));
        assert_eq!(0, super::tern(true == false, 5, 0));
    }
}