Benign cargo Download

sort-panic-safe.rs

Contains an unbounded block loopRust test marker or harness
SHA-2562058c5f46ad2a98ea18575180321005cf5f8726c239d8f44a528dbc6b1083435
MaleculeH(Db)Md(Pa)

Evidence

imports rand::distributions::Uniform lines 3–19
3:4… ern crate rayon;
4extern crate rand;
5
6use rand::{thread_rng, Rng};
7use rand::distributions::Uniform;
8use rayon::prelude::*;
9use std::cell::Cell;
10use std::cmp::{self, Ordering};
11use std::panic;
12use std::sync::atomic::Ordering::Relaxed;
13use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize};
14use std::thread;
15
16static VERSIONS: AtomicUsize = ATOMIC_USIZE_INIT;
17
18lazy_static! {
19 static ref DROP_COUNTS: …
English function-word token "for" lines 19–33
⋯10 lines
29}
30
31impl PartialEq for DropCounter {
32 fn eq(&self, other: &Self) -> bool {
33 self.partial_cmp(other) == Some( …
English function-word token "the" lines 61–67
61:6… let len = $input.len();
62
63 // Work out the total number of comparisons required to sort
64 // this array...
65 let count = AtomicUsize::new(0);
66 $input.to_owned().$func(|a, b| {
67 …
Contains an unbounded block loop lines 75–83
75:26… anic_countdown / 10)
76 };
77
78 // ... and then panic after each `step` comparisons.
79 loop {
80 // Refresh the counters.
81 VERSIONS.store(0, Relaxed);
82 for i in 0..len {
83 DROP …
#[test] attribute lines 119–125
119:6… d_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
120
121#[test]
122fn sort_panic_safe() {
123 let prev = panic::take_hook();
124 panic::set_hook(Box::new(move |info| {
125 if !SILENCE_PANIC. …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.