sort_it/lib.rs
1//! # Mandatory readme
2//!
3//! This crate provides various different sorting algorithms both implemented directly on
4//! any `Vec` implementing certain things and also as standalone functions.
5//!
6//! # Examples
7//!
8//! Using the trait implementations:
9//!
10//! ```rust
11//! use sort_it::prelude::*;
12//!
13//! fn main() {
14//! let mut v = vec![9, 8, 7, 6, 5, 4, 3, 2, 1];
15//!
16//! println!("original v: {:?}", v.clone());
17//!
18//! v.gnome_sort(); // sorts `v` via gnome sort (with the trait implementation).
19//!
20//! println!("sorted v: {:?}", v);
21//! }
22//! ```
23//!
24//! Without using the trait implementations:
25//!
26//! ```rust
27//! use sort_it::prelude::*;
28//! use rand::prelude::*;
29//!
30//! fn main() {
31//! let mut rng = rand::thread_rng();
32//!
33//! let mut v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
34//!
35//! v.shuffle(&mut rng); // randomly shuffles `v`.
36//!
37//! let s = merge_sort(v.clone()); // returns a sorted copy of `v` via merge sort (without the trait implementation).
38//!
39//! println!("v: {:?}, s: {:?}", v, s);
40//! }
41//! ```
42//!
43//! # Implemented sorting algorithms:
44//!
45//! * Bogosort
46//! * Bubble Sort
47//! * Gnome Sort
48//! * Insertion Sort
49//! * Merge Sort
50//! * Selection Sort
51//! * Slowsort
52//! * Stooge Sort
53//!
54//! Have fun sorting things in different ways.
55
56#[cfg(test)]
57mod tests;
58
59pub mod algorithms;
60
61pub mod prelude {
62 pub use crate::algorithms::*;
63}
64