#queue #custom #box #generic #instance #dummy #enqueue

bin+lib dummy-queue

A dummy implementation of queue in rust

3 stable releases

1.1.0 Sep 30, 2023
1.0.1 Sep 30, 2023

#10 in #dummy

Download history 2/week @ 2024-02-15 10/week @ 2024-02-22 3/week @ 2024-02-29 1/week @ 2024-03-07 1/week @ 2024-03-14 43/week @ 2024-03-28 28/week @ 2024-04-04

71 downloads per month

MIT license

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());
    }
}

No runtime deps