rust/library/core/tests/bool.rs

8 lines
205 B
Rust
Raw Normal View History

2019-09-07 09:49:27 -05:00
#[test]
fn test_bool_to_option() {
2019-12-06 06:18:32 -06:00
assert_eq!(false.then_some(0), None);
assert_eq!(true.then_some(0), Some(0));
assert_eq!(false.then(|| 0), None);
assert_eq!(true.then(|| 0), Some(0));
2019-09-07 09:49:27 -05:00
}