default fn to_vec<A: Allocator>(s: &[Self], alloc: A) -> Vec<Self, A> {
            struct DropGuard<'a, T, A: Allocator> {
                vec: &'a mut Vec<T, A>,
                num_init: usize,
            }
            impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
                #[inline]
                fn drop(&mut self) {
                    // SAFETY:
                    // items were marked initialized in the loop below
                    unsafe {
                        self.vec.set_len(self.num_init);
                    }
                }
            }
            let mut vec = Vec::with_capacity_in(s.len(), alloc);
            let mut guard = DropGuard { vec: &mut vec, num_init: 0 };
            let slots = guard.vec.spare_capacity_mut();
            // .take(slots.len()) is necessary for LLVM to remove bounds checks
            // and has better codegen than zip.
            for (i, b) in s.iter().enumerate().take(slots.len()) {
                guard.num_init = i;
                slots[i].write(b.clone());
            }
            core::mem::forget(guard);
            // SAFETY:
            // the vec was allocated and initialized above to at least this length.
            unsafe {
                vec.set_len(s.len());
            }
            vec
        }
Sorts the slice.

This sort is stable (i.e., does not reorder equal elements) and *O*(*n* \* log(*n*)) worst-case.

When applicable, unstable sorting is preferred because it is generally faster than stable
sorting and it doesn't allocate auxiliary memory.
See [`sort_unstable`](slice::sort_unstable).

# Current implementation

The current algorithm is an adaptive, iterative merge sort inspired by
[timsort](https://en.wikipedia.org/wiki/Timsort).
It is designed to be very fast in cases where the slice is nearly sorted, or consists of
two or more sorted sequences concatenated one after another.

Also, it allocates temporary storage half the size of `self`, but for short slices a
non-allocating insertion sort is used instead.

# Examp
benchmarks/haystacks/code/rust-library.rs