Crates.io | dummy-queue |
lib.rs | dummy-queue |
version | 1.1.0 |
source | src |
created_at | 2023-09-30 00:01:54.993584 |
updated_at | 2023-09-30 00:32:15.38173 |
description | A dummy implementation of queue in rust |
homepage | |
repository | |
max_upload_size | |
id | 988230 |
size | 3,874 |
Custom (and basic) implementation of queue using Box
.
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());
}
}