-
Notifications
You must be signed in to change notification settings - Fork 4
/
0145-slice-deque.rs
48 lines (41 loc) · 1014 Bytes
/
0145-slice-deque.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*!
```rudra-poc
[target]
crate = "slice-deque"
version = "0.3.0"
[report]
issue_date = 2021-02-19
issue_url = "https://github.com/gnzlbg/slice_deque/issues/90"
rustsec_url = "https://github.com/RustSec/advisory-db/pull/846"
rustsec_id = "RUSTSEC-2021-0047"
[[bugs]]
analyzer = "UnsafeDataflow"
bug_class = "PanicSafety"
rudra_report_locations = ["src/lib.rs:3016:5: 3040:6"]
```
!*/
#![forbid(unsafe_code)]
use slice_deque::SliceDeque;
struct DropDetector(u32);
impl Drop for DropDetector {
fn drop(&mut self) {
println!("Dropping {}", self.0);
}
}
fn main() {
let mut deq = SliceDeque::new();
deq.push_back(DropDetector(1));
deq.push_back(DropDetector(2));
deq.push_back(DropDetector(3));
let drained = deq
.drain_filter(|x| {
if x.0 == 1 {
true
} else if x.0 == 2 {
false
} else {
panic!("predicate panicked!");
}
})
.collect::<SliceDeque<_>>();;
}