2021-06-27 01:22:46 -05:00
|
|
|
// edition:2021
|
2021-02-23 22:39:33 -06:00
|
|
|
//check-pass
|
|
|
|
#![warn(unused)]
|
|
|
|
#![feature(rustc_attrs)]
|
2023-04-08 17:37:21 -05:00
|
|
|
#![feature(btree_extract_if)]
|
2021-02-23 22:39:33 -06:00
|
|
|
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use std::panic::{catch_unwind, AssertUnwindSafe};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut map = BTreeMap::new();
|
|
|
|
map.insert("a", ());
|
|
|
|
map.insert("b", ());
|
|
|
|
map.insert("c", ());
|
|
|
|
|
|
|
|
{
|
2023-04-08 17:37:21 -05:00
|
|
|
let mut it = map.extract_if(|_, _| true);
|
2021-02-23 22:39:33 -06:00
|
|
|
catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err();
|
|
|
|
let result = catch_unwind(AssertUnwindSafe(|| it.next()));
|
|
|
|
assert!(matches!(result, Ok(None)));
|
|
|
|
}
|
|
|
|
|
2021-02-25 17:03:41 -06:00
|
|
|
{
|
2023-04-08 17:37:21 -05:00
|
|
|
let mut it = map.extract_if(|_, _| true);
|
2021-02-25 17:03:41 -06:00
|
|
|
catch_unwind(AssertUnwindSafe(|| while let Some(_) = it.next() {})).unwrap_err();
|
|
|
|
let result = catch_unwind(AssertUnwindSafe(|| it.next()));
|
|
|
|
assert!(matches!(result, Ok(None)));
|
|
|
|
}
|
|
|
|
|
2021-02-23 22:39:33 -06:00
|
|
|
}
|