3 stable releases
1.1.0 | Sep 30, 2023 |
---|---|
1.0.1 | Sep 30, 2023 |
#15 in #custom
4KB
72 lines
dummy-queue
Custom (and basic) implementation of queue using Box
.
Usage
Queue
supports T
type means generic, so you are in charge to impl (if needed) any trait in case your use cases requires it. Any instance of T
needs to be mut
, otherwise Rust won't compile your code.
fn main() {
let mut queue = Queue::<i32>::new();
queue.enqueue(1);
queue.enqueue(2);
queue.enqueue(4);
queue.enqueue(5);
println!("Front of the queue: {:?}", queue.front());
while !queue.is_empty() {
println!("Dequeued: {:?}", queue.dequeue());
}
}