2 unstable releases
0.2.0 | Jun 29, 2021 |
---|---|
0.1.0 | Jun 29, 2021 |
#2160 in Data structures
22KB
483 lines
lobby-queue
A const-size queue-like data structure.
Usage
Add lobby-queue to your Cargo.toml
:
[dependencies]
lobby-queue = "0.2"
And use it:
use lobby_queue::Lobby;
fn main() {
let mut m = Lobby::new([None, None, None]);
m.push(0);
m.push(1);
m.push(2);
assert_eq!(Some(&0), m.first());
let v0 = m.push(3);
assert_eq!(Some(0), v0);
assert_eq!(Some(&1), m.first());
for v in m {
println!("{}", v);
}
}
lib.rs
:
This crate provides a const-size queue-like data structure. When full, pushing new items will remove the head (first-added) items.
[dependencies]
lobby-queue = "0.2"
use lobby_queue::Lobby;
let mut m = Lobby::new([None, None, None]);
m.push(0);
m.push(1);
m.push(2);
assert_eq!(Some(&0), m.first());
let v0 = m.push(3);
assert_eq!(Some(0), v0);
assert_eq!(Some(&1), m.first());
for v in m {
println!("{}", v);
}