rust/library/core/tests/bool.rs

8 lines
205 B
Rust
Raw Normal View History

2019-09-07 16:49:27 +02:00
#[test]
fn test_bool_to_option() {
2019-12-06 13:18:32 +01: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 16:49:27 +02:00
}