#no-std #vec #queue #spsc #deque

no-std fixed-queue

no_std, no_alloc, use [T; N]. support Vec/VecDeque/spsc/History

13 unstable releases (3 breaking)

0.3.10 Jul 27, 2021
0.3.9 Apr 11, 2021
0.3.8 Mar 29, 2021
0.2.0 Mar 22, 2021
0.0.1 Mar 22, 2021

#10 in #deque

36 downloads per month
Used in 11 crates (4 directly)

Custom license

22KB
664 lines

Fixed-Queue

A heapless version of the Rust Vec, VecDeque.

no_std, no_alloc, use [T; N].

support Vec/VecDeque/spsc/History.

Deprecated

Replaced by heapless.

Usage

Vec

use fixed_queue::Vec;

let mut vec: Vec<u8, 3> = Vec::new();
assert_eq!(vec.capacity(), 3);
assert!(vec.is_empty());
vec.push(1);
println!("{}", vec[0]);
println!("{:?}", vec.pop());

VecDeque

use fixed_queue::VecDeque;

let mut vec: VecDeque<u8, 4> = VecDeque::new();
assert_eq!(vec.capacity(), 3);
assert!(vec.is_empty());
vec.push_back(1);
println!("{}", vec[0]);
vec.push_front(2);
println!("{}", vec[1]);
println!("{:?}", vec.pop_back());
println!("{:?}", vec.pop_front());

SPSC

use fixed_queue::Spsc;
static SPSC: Spsc<u8, 4> = Spsc::new();

let sender = SPSC.take_sender().unwrap();
let recver = SPSC.take_recver().unwrap();

assert_eq!(SPSC.capacity(), 3);
assert!(sender.send(1).is_ok());
assert!(sender.send(2).is_ok());
assert!(sender.send(3).is_ok());
assert!(sender.send(4).is_err());

History

use fixed_queue::History;
static HISTORY: History<u8, 3> = History::new();

assert!(HISTORY.insert(1));
assert!(HISTORY.contains(&1));

No runtime deps