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
//! rust_sort is a collection of sorting algorithms implemented purely for educational purposes.
//!
//! - bubble sort
//! - selection sort
//! - insertion sort
//!
//! TODO
//! - cocktail sort
//! - merge sort
//! - quick sort
//! - tim sort
//! - heap sort
//! - counting sort
//! - bucket sort
//! - radix sort
//! - bogo sort
//! - sleep sort

pub mod bubble_sort;
pub mod insertion_sort;
pub mod selection_sort;

use std::fmt::{Debug, Display};

// macros to enable trait aliasing
macro_rules! items {
    ($($item:item)*) => ($($item)*);
}

macro_rules! trait_alias {
    ($name:ident = $($base:tt)+) => {
        items! {
            pub trait $name: $($base)+ { }
            impl<T: $($base)+> $name for T { }
        }
    };
}

// Sortable trait alias used in all sort algs
trait_alias!(Sortable = PartialOrd + Copy + Display + Debug);