rust_sort/
lib.rs

1//! rust_sort is a collection of sorting algorithms implemented purely for educational purposes.
2//!
3//! - bubble sort
4//! - selection sort
5//! - insertion sort
6//! - cocktail sort
7//! - merge sort
8//! - quick sort
9//!
10//! TODO
11//! - tim sort
12//! - heap sort
13//! - counting sort
14//! - bucket sort
15//! - radix sort
16//! - bogo sort
17//! - sleep sort
18
19pub mod bubble_sort;
20pub mod insertion_sort;
21pub mod selection_sort;
22pub mod cocktail_sort;
23pub mod merge_sort;
24pub mod quick_sort;
25
26use std::fmt::{Debug, Display};
27
28// macros to enable trait aliasing
29macro_rules! items {
30    ($($item:item)*) => ($($item)*);
31}
32
33macro_rules! trait_alias {
34    ($name:ident = $($base:tt)+) => {
35        items! {
36            pub trait $name: $($base)+ { }
37            impl<T: $($base)+> $name for T { }
38        }
39    };
40}
41
42// Sortable trait alias used in all sort algs
43trait_alias!(Sortable = PartialOrd + Copy + Display + Debug);