Benign cargo download unavailable

mergesort.rs

Rust test marker or harness
SHA-2561e5d48bbfcee289acd66ba7c75d128f237032d07b74ca9975109c640109511a5
MaleculeMd(Pa)

Evidence

imports iter::* lines 1–17
1//! Parallel merge sort.
2//!
3//! This implementation is copied verbatim from `std::slice::sort` and then parallelized.
4//! The only difference from the original is that the sequential `mergesort` returns
5//! `MergesortResult` and leaves descending arrays intact.
6
7use iter::*;
8use rayon_core;
9use slice::ParallelSliceMut;
10use std::mem::size_of;
11use std::mem;
12use std::ptr;
13use std::slice;
14
15unsafe fn get_and_increment<T>(ptr: &mut *mut T) -> *mut T {
16 let old = *ptr;
17 *ptr = p …
English function-word token "for" lines 29–36
29:3… dest: *mut T,
30 len: usize,
31}
32
33impl<T> Drop for CopyOnDrop<T> {
34 fn drop(&mut self) {
35 unsafe {
36 ptr::copy_nonoverlapping( …
English function-word token "with" lines 63–66
63:78… ghtly better
64 // performance than with the 2nd method.
65 //
66 // All methods were benchmarked, and the 3rd showed …
English function-word token "have" lines 433–438
433:2… //
434/// # Safety
435///
436/// The `dest` pointer must have enough space to store the result.
437///
438/// Even if `is_less` panics at any point during the merg …
imports rand::distributions::Uniform lines 712–727
712:20… s_mut_ptr(), buf as *mut T, &chunks, false, &is_less);
713 }
714}
715
716#[cfg(test)]
717mod tests {
718 use rand::{thread_rng, Rng};
719 use rand::distributions::Uniform;
720 use super::split_for_merge;
721
722 #[test]
723 fn test_split_for_merge() {
724 fn check(left: &[u32], right: &[u32]) {
725 let (l, r) = split_for_merge(left, right, &|&a, &b| a < b);
726 assert!(left[..l].iter().all(|&x| right[r..].iter().all(|&y| x <= y)));
727 assert!(right[..r].iter().all(|&x| l …

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.