Crates.io | trait-based-collection-macros |
lib.rs | trait-based-collection-macros |
version | 0.1.0 |
source | src |
created_at | 2022-10-22 10:23:49.851009 |
updated_at | 2022-10-22 10:23:49.851009 |
description | The procedural macros for the collection crate |
homepage | https://github.com/ferranSanchezLlado/rust-data-structures.git |
repository | https://github.com/ferranSanchezLlado/rust-data-structures.git |
max_upload_size | |
id | 694331 |
size | 37,924 |
This project is a collection of data structures that implement the Collection
trait, allowing for a common interface
for all the data structures in this crate. This crate is intended to be a proof of concept a common interface for all
the data structures in Rust.
This crate contains three major traits:
Collection
: A trait that defines the basic operations of a collection.FixedSizeCollection
: A trait that defines the basic operations of a collection with a fixed size.Iterators
: A trait that encapsulates all the iterators of a collection.This crate contains the following data structures:
Queue
: A FIFO
data structure based on linked nodes.Deque
: A FIFO
and LIFO
data structure based on linked nodes.CircularDeque
: A FIFO
and LIFO
data structure based on a circular array.Stack
: A LIFO
data structure based on a linked nodes.ArrayStack
: A LIFO
data structure based on a fixed size array.BinaryHeap
: A PriorityQueue
data structure based on a binary heap.For more information, please refer to the individual documentation of each data structure. This can be generated by
running cargo doc --open
.
From crates.io:
[dependencies]
trait-based-collection = "0.1"
Alternatively, you can clone this repository and build it from source:
git clone https://github.com/ferranSanchezLlado/rust-data-structures.git
cd r
cargo install --force --path .
If there are installation errors, ensure that your toolchain is up-to-date. For the latest, run:
rustup update
use trait_based_collection::{import, Queue};
import!();
fn main() {
let mut q = queue![1, 2, 3, 4, 5];
println!("Queue: {:?}", q);
println!("Queue size: {}", q.len());
println!("Queue is empty: {}", q.is_empty());
q.add(6);
q.remove();
for i in q.iter() {
println!("Queue element: {}", i);
}
}
Data Structures to implement: