Skip to main content

data_structures_lib/
lib.rs

1//! Data Structures Library for Rust
2//!
3//! A comprehensive, zero-dependency collection of fundamental data structures.
4
5use std::fmt;
6
7/// Errors that can be returned by data structure operations.
8#[derive(Debug, Clone, PartialEq)]
9pub enum Error {
10    Empty,
11    NotFound,
12    OutOfBounds,
13    InvalidArgument,
14}
15
16impl fmt::Display for Error {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            Error::Empty => write!(f, "structure is empty"),
20            Error::NotFound => write!(f, "not found"),
21            Error::OutOfBounds => write!(f, "index out of range"),
22            Error::InvalidArgument => write!(f, "invalid argument"),
23        }
24    }
25}
26
27impl std::error::Error for Error {}
28
29pub mod caches;
30pub mod graphs;
31pub mod hashing;
32pub mod heaps;
33pub mod linear;
34pub mod probabilistic;
35pub mod trees;
36pub mod tries;
37
38pub use caches::LruCache;
39pub use graphs::{AdjacencyListGraph, AdjacencyMatrixGraph};
40pub use hashing::{HashMap, HashSet};
41pub use heaps::{Heap, MaxHeap, MinHeap};
42pub use linear::{
43    CircularLinkedList, DoublyLinkedList, DynamicArray, Queue, SinglyLinkedList, Stack,
44};
45pub use probabilistic::BloomFilter;
46pub use trees::{AvlTree, BinarySearchTree};
47pub use tries::Trie;